Changeset 440

Show
Ignore:
Timestamp:
08/03/07 21:45:52 (1 year ago)
Author:
ziz
Message:

Add handling of \r\n terminations under MACH_O_CARBON in my_fgets to fix double-spacing of help files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/z-file.c

    r366 r440  
    159159        char *s = buf; 
    160160        int len; 
    161  
     161         
     162#ifdef MACH_O_CARBON 
     163         
     164        /* For the \r vs. \r\n vs \n handling code below */ 
     165        bool seen_cr = FALSE; 
     166 
     167#endif /* MACH_O_CARBON */ 
    162168 
    163169        /* Paranoia */ 
     
    203209                 * end of line, especially since the introduction of OS X. 
    204210                 * MPW tools were also very tolerant to the Unix EOL. 
     211                 * 
     212                 * Watch for \r; when found, set flag and advance. 
     213                 * If the next character isn't \n, rewind the file one character  
     214                 * and act like we found \n anyway to end the line. 
    205215                 */ 
    206                 if (c == '\r') c = '\n'; 
     216                if (c == '\r')  
     217                { 
     218                        seen_cr = TRUE; 
     219                        continue; 
     220                } 
     221                else 
     222                        seen_cr = FALSE; 
     223                         
     224                if (seen_cr && c != '\n') 
     225                { 
     226                        fseek(fff, -1, SEEK_CUR); 
     227                         
     228                        /* Put a fake newline in to end the line */ 
     229                        c = '\n'; 
     230                } 
    207231 
    208232#endif /* MACH_O_CARBON */