www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/06/15/07:09:37

Date: Mon, 15 Jun 92 12:14:51 +0200
From: nils AT sonya DOT exp-math DOT uni-essen DOT de (Nils Rennebarth)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: sort.cc Bug correction

The following changes have to be made in the sample-Program sort.cc
to compile without warnings (changes 1-3: unsigned char -> char)
and not to crash with Segmentation violation when no filename argument
is given (i.e. standard input is to be sorted).
(at least this is true on my AT 486/33 clone).
It's not that much important, but it is the first time I used the compiler
and it was the first program I tried to compile and the result was a crash,
which was a bit disencouraging.
*** sort.cc	Sun Jun 14 12:27:30 1992
--- sortold.cc	Wed Mar 20 21:51:18 1991
***************
*** 6,11 ****
    ENTRY *before, *after;
    ENTRY *same;
!   char *line;
!   char *sort_ptr;
    ENTRY();
    ~ENTRY();
--- 6,11 ----
    ENTRY *before, *after;
    ENTRY *same;
!   unsigned char *line;
!   unsigned char *sort_ptr;
    ENTRY();
    ~ENTRY();
***************
*** 32,36 ****
  ENTRY *eroot=0;
  
! void read_one_data(char *s)
  {
    ENTRY *e, **eptr;
--- 32,36 ----
  ENTRY *eroot=0;
  
! void read_one_data(unsigned char *s)
  {
    ENTRY *e, **eptr;
***************
*** 78,82 ****
  void read_data(FILE *f)
  {
!   char buf[1024];
    while (fgets(buf, 1024, f) != NULL)
    {
--- 78,82 ----
  void read_data(FILE *f)
  {
!   unsigned char buf[1024];
    while (fgets(buf, 1024, f) != NULL)
    {
***************
*** 105,109 ****
  {
    int i;
!   while (argc > 1)
    {
      if (argv[1][0] == '+')
--- 105,109 ----
  {
    int i;
!   while (1)
    {
      if (argv[1][0] == '+')

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019