From a3c069777c4baaf7cf8ac2d21d05df8b988ca67d Mon Sep 17 00:00:00 2001 From: gdr Date: Wed, 8 Feb 1995 05:05:49 +0000 Subject: [PATCH] The comments on the previous checkin were a bit premature. The enclosed files are the released version 1.13, minus the files "udl" and "udl.r". --- usr.orca.bin/udl/Makefile.gs | 15 ++-- usr.orca.bin/udl/Makefile.unx | 2 +- usr.orca.bin/udl/README | 12 ++- usr.orca.bin/udl/common.c | 160 ++++++++++++++++++---------------- usr.orca.bin/udl/common.h | 5 +- usr.orca.bin/udl/describe.udl | 9 ++ usr.orca.bin/udl/udl.1 | 44 +++++++--- usr.orca.bin/udl/udlgs.c | 113 +++++++++++++----------- usr.orca.bin/udl/udlunix.c | 57 ++++++------ usr.orca.bin/udl/udluse.c | 5 +- 10 files changed, 241 insertions(+), 181 deletions(-) create mode 100644 usr.orca.bin/udl/describe.udl diff --git a/usr.orca.bin/udl/Makefile.gs b/usr.orca.bin/udl/Makefile.gs index c171d24..90ec182 100644 --- a/usr.orca.bin/udl/Makefile.gs +++ b/usr.orca.bin/udl/Makefile.gs @@ -3,7 +3,7 @@ # Copyright (c) 1993-1994 Soenke Behrens # For use with dmake # -# $Id: Makefile.gs,v 1.1 1994/12/13 18:08:13 gdr Exp $ +# $Id: Makefile.gs,v 1.3 1995/02/08 05:15:20 gdr Exp $ # # Define the following as necessary: # @@ -20,20 +20,25 @@ # GNO if you are compiling on the IIgs. This will allow for both # ':' and '/' as pathname separators. # +# OVERFLOW_CHECK Udl uses one recursive subroutine. Define this if +# you want to check for stack overflows for this routine (independent +# of any compiler flags). Strongly recommended. +# # CHECK_STACK if you want stack usage to be displayed (IIgs only). # You will also have to specify -l/usr/lib/stack in LDFLAGS. -DEFINES = -DGNO -D_POSIX_C_SOURCE -D_POSIX_SOURCE -DHAS_ATEXIT -DCHECK_STACK -CFLAGS = $(DEFINES) -G25 -w -v -LDFLAGS = -v -l/usr/lib/stack -l/usr/lib/gnulib +DEFINES = -DGNO -D_POSIX_C_SOURCE -D_POSIX_SOURCE -DHAS_ATEXIT \ + -DOVERFLOW_CHECK +CFLAGS = $(DEFINES) -O -w -v -s2048 +LDFLAGS = -v -l/usr/lib/gnulib -s2048 # # You should not have to modify anything beyond this point # udl: udl.o udluse.o udl.r common.o +# cp udl.r udl $(CC) $(LDFLAGS) -o udl udl.o udluse.o common.o - copyfork udl.r udl udl.o: udl.gs.c common.h $(CC) -c $(CFLAGS) -o udl.o udl.gs.c diff --git a/usr.orca.bin/udl/Makefile.unx b/usr.orca.bin/udl/Makefile.unx index a05fc51..85927a0 100644 --- a/usr.orca.bin/udl/Makefile.unx +++ b/usr.orca.bin/udl/Makefile.unx @@ -2,7 +2,7 @@ # Makefile for udl # (c) 1993-1994 Soenke Behrens # -# $Id: Makefile.unx,v 1.1 1994/12/13 18:08:16 gdr Exp $ +# $Id: Makefile.unx,v 1.3 1995/02/08 05:15:22 gdr Exp $ # # Define the following as necessary: # diff --git a/usr.orca.bin/udl/README b/usr.orca.bin/udl/README index bc96ed8..6c996cf 100644 --- a/usr.orca.bin/udl/README +++ b/usr.orca.bin/udl/README @@ -4,7 +4,7 @@ udl - Convert EOL formats freely between MS-DOS (CR/LF), Unix/Amiga (LF), (c) 1993-1994 Soenke Behrens - Version 1.13: $Id: README,v 1.1 1994/12/13 18:08:18 gdr Exp $ + Version 1.13: $Id: README,v 1.2 1995/02/08 05:05:36 gdr Exp $ ============================================================================= Udl converts text files between CR, LF and CR/LF (Apple, Unix and MS-DOS). @@ -46,6 +46,9 @@ v1.13 Added ability to recurse through directories (-R flag). Changed behavior to ignore binary files rather than exiting. Merged Unix and Apple IIgs versions. + No message is printed out when a binary file (or, in the IIgs + implementation, a non-TXT or non-SRC file) is encountered + unless the -v option is specified. ========= Compiling: @@ -66,6 +69,13 @@ Also, udl.c assumes that getopt() is declared in and that the function strdup() exists in . You might want to change these includes if that's not the case. +========== +Legalities: +========== + +This program contains material from the Orca/C Run-Time Libraries, +copyright 1987-1994 by Byte Works, Inc. Used with permission. + ============================================================================= Enjoy, diff --git a/usr.orca.bin/udl/common.c b/usr.orca.bin/udl/common.c index 31a8f73..b9bb7e7 100644 --- a/usr.orca.bin/udl/common.c +++ b/usr.orca.bin/udl/common.c @@ -4,7 +4,7 @@ * * Routines common to both the Unix and Apple IIgs versions. * - * $Id: common.c,v 1.1 1994/12/13 18:08:20 gdr Exp $ + * $Id: common.c,v 1.2 1995/02/08 05:05:38 gdr Exp $ * * Copyright (c) 1993-1994 Soenke Behrens */ @@ -56,36 +56,36 @@ void convert_gs(FILE *infile, FILE *outfile) { *out_bufpos = '\r'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\r',outfile); */ } else if(a == '\r') { *out_bufpos = '\r'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\r',outfile); */ if (*in_bufpos == '\n' && file_remain != 0) { - in_bufpos++; - - if (in_bufpos >= in_bufend) { - file_remain -= in_bufend - in_buffer; - in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); - in_bufpos = in_buffer; - } + in_bufpos++; + + if (in_bufpos >= in_bufend) { + file_remain -= in_bufend - in_buffer; + in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); + in_bufpos = in_buffer; + } } /* if ((a = fgetc (infile)) != '\n') - ungetc (a,infile); */ + ungetc (a,infile); */ } else { *out_bufpos = a; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc(a,outfile); */ } @@ -139,52 +139,52 @@ void convert_messy (FILE *infile, FILE *outfile) { *out_bufpos = '\r'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\r',outfile); */ *out_bufpos = '\n'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\n',outfile); */ } else if(a == '\r') { *out_bufpos = '\r'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\r',outfile); */ *out_bufpos = '\n'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\n',outfile); */ if (*in_bufpos == '\n' && file_remain != 0) { - in_bufpos++; + in_bufpos++; - if (in_bufpos >= in_bufend) { - file_remain -= in_bufend - in_buffer; - in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); - in_bufpos = in_buffer; - } + if (in_bufpos >= in_bufend) { + file_remain -= in_bufend - in_buffer; + in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); + in_bufpos = in_buffer; + } } /* if ((a = fgetc (infile)) != '\n') - ungetc (a,infile); */ + ungetc (a,infile); */ } else { *out_bufpos = a; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc(a,outfile); */ } @@ -238,28 +238,28 @@ void convert_tunix (FILE *infile, FILE *outfile) { *out_bufpos = '\n'; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc('\n',outfile); */ if (*in_bufpos == '\n' && file_remain != 0) { - in_bufpos++; + in_bufpos++; - if (in_bufpos >= in_bufend) { - file_remain -= in_bufend - in_buffer; - in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); - in_bufpos = in_buffer; - } + if (in_bufpos >= in_bufend) { + file_remain -= in_bufend - in_buffer; + in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); + in_bufpos = in_buffer; + } } /* if ((a = fgetc (infile)) != '\n') - ungetc (a,infile); */ + ungetc (a,infile); */ } else { *out_bufpos = a; out_bufpos++; if (out_bufpos == out_bufend) { - my_fwrite(out_buffer,outfile,BUFFERSIZE); - out_bufpos = out_buffer; + my_fwrite(out_buffer,outfile,BUFFERSIZE); + out_bufpos = out_buffer; } /* fputc(a,outfile); */ } @@ -308,7 +308,7 @@ int convert_fast_gs(FILE *infile, FILE *outfile) { case apple: if (verbose) printf("%s: %s is already in Apple format, skipping.\n", - program_name,current_file); + program_name,current_file); return (FALSE); break; @@ -317,17 +317,17 @@ int convert_fast_gs(FILE *infile, FILE *outfile) { while (file_remain != 0) { a = *in_bufpos; if (a == '\n') - *in_bufpos++ = '\r'; + *in_bufpos++ = '\r'; else if (a == '\0') { /* End of buffer reached */ - - /* Write changed buffer out */ - my_fwrite(in_buffer,outfile,in_bufend - in_buffer); - - /* And reload it */ - file_remain -= in_bufend - in_buffer; - in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); - *in_bufend = '\0'; - in_bufpos = in_buffer; + + /* Write changed buffer out */ + my_fwrite(in_buffer,outfile,in_bufend - in_buffer); + + /* And reload it */ + file_remain -= in_bufend - in_buffer; + in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); + *in_bufend = '\0'; + in_bufpos = in_buffer; } else in_bufpos++; } return (TRUE); @@ -387,7 +387,7 @@ int convert_fast_messy (FILE *infile, FILE *outfile) { case dos: if (verbose) printf("%s: %s is already in MS-DOS format, skipping.\n", - program_name,current_file); + program_name,current_file); return (FALSE); break; @@ -448,7 +448,7 @@ int convert_fast_tunix (FILE *infile, FILE *outfile) { case tunix: if (verbose) printf("%s: %s is already in Unix format, skipping.\n", - program_name,current_file); + program_name,current_file); return (FALSE); break; @@ -457,17 +457,17 @@ int convert_fast_tunix (FILE *infile, FILE *outfile) { while (file_remain != 0) { a = *in_bufpos; if (a == '\r') - *in_bufpos++ = '\n'; + *in_bufpos++ = '\n'; else if (a == '\0'){ /* End of buffer reached */ - /* Write changed buffer out */ - my_fwrite(in_buffer,outfile,in_bufend - in_buffer); + /* Write changed buffer out */ + my_fwrite(in_buffer,outfile,in_bufend - in_buffer); - /* And reload */ - file_remain -= in_bufend - in_buffer; - in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); - *in_bufend = '\0'; - in_bufpos = in_buffer; + /* And reload */ + file_remain -= in_bufend - in_buffer; + in_bufend = in_buffer + my_fread(infile, BUFFERSIZE); + *in_bufend = '\0'; + in_bufpos = in_buffer; } else in_bufpos++; } return (TRUE); @@ -513,9 +513,9 @@ enum file_format get_file_format (unsigned char *buffer) { break; } else if (c == '\r') { if (*buffer == '\n') - result = dos; + result = dos; else - result = apple; + result = apple; break; } } @@ -523,8 +523,8 @@ enum file_format get_file_format (unsigned char *buffer) { if (result == 0) { if (verbose) printf("%s: No EOL found on the first %d bytes " - "of %s. Might be a binary file. File skipped\n", - program_name,BUFFERSIZE, current_file); + "of %s. Might be a binary file. File skipped\n", + program_name,BUFFERSIZE, current_file); result = binary; } @@ -625,14 +625,14 @@ void copy_file (char *from, char *to) { length = fread(buffer,1,BUFFERSIZE,fp1); if (ferror(fp1)) { fprintf(stderr,"%s: Error while trying to read %s\n", - program_name, from); + program_name, from); free (buffer); exit (EXIT_FAILURE); } if (fwrite(buffer,1,length,fp2) != length) { fprintf(stderr,"%s: Error while trying to write out " - "file %s\n",program_name,to); + "file %s\n",program_name,to); free (buffer); exit (EXIT_FAILURE); } @@ -717,8 +717,19 @@ void build_file_list(char *file, short recurse) { DIR *dir; struct dirent *entry; + /* check for stack overflow */ + recursionDepth++; +#ifdef OVERFLOW_CHECK + if ((recursionDepth * BYTES_PER_DEPTH + BASESIZE) > STACKSIZE) { + fprintf(stderr,"%s: Exceeded permitted nesting depth (%d levels)\n" + "Aborted.\n",program_name,recursionDepth); + exit(EXIT_FAILURE); + } +#endif + if (stat(file,&tstat)!=0) { fprintf(stderr,"%s: Couldn't stat %s. File skipped\n",program_name,file); + --recursionDepth; return; } @@ -790,6 +801,7 @@ void build_file_list(char *file, short recurse) { add_to_pathList(currentDirectory, file); } + --recursionDepth; return; } @@ -801,13 +813,13 @@ void add_to_pathList(char *thisdir, char *file) { pathSlots += PATHLIST_QUANTUM; #if BROKEN_REALLOC if ((pathList==NULL) && - ((pathList = malloc((pathSlots+1) * sizeof(char *)))==NULL)) { + ((pathList = malloc((pathSlots+1) * sizeof(char *)))==NULL)) { fprintf(stderr,"%s: Couldn't expand pathList\n",program_name); exit (EXIT_FAILURE); } else { if ((p = realloc(pathList, (pathSlots+1) * sizeof(char *)))==NULL) { - fprintf(stderr,"%s: Couldn't expand pathList\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr,"%s: Couldn't expand pathList\n",program_name); + exit (EXIT_FAILURE); } pathList = p; } @@ -823,7 +835,7 @@ void add_to_pathList(char *thisdir, char *file) { pathList[pathSlotsUsed] = malloc(strlen(thisdir)+strlen(file)+2); if (pathList[pathSlotsUsed] == NULL) { fprintf(stderr,"%s: Couldn't duplicate filename %s%c%s\n",program_name, - thisdir,dirbrk,file); + thisdir,dirbrk,file); exit (EXIT_FAILURE); } if (*thisdir) { diff --git a/usr.orca.bin/udl/common.h b/usr.orca.bin/udl/common.h index d33fb7e..5a13080 100644 --- a/usr.orca.bin/udl/common.h +++ b/usr.orca.bin/udl/common.h @@ -4,7 +4,7 @@ * * Header file for routines common to both the Unix and Apple IIgs versions. * - * $Id: common.h,v 1.1 1994/12/13 18:08:23 gdr Exp $ + * $Id: common.h,v 1.2 1995/02/08 05:05:40 gdr Exp $ * * Copyright (c) 1993-1994 Soenke Behrens */ @@ -24,6 +24,9 @@ #define BUFFERSIZE 0x2000 #define PATHLIST_QUANTUM 20 #define UDL_VERSION "Version 1.13" +#define STACKSIZE 2048 +#define BYTES_PER_DEPTH 40 +#define BASESIZE 700 #ifndef FALSE # define FALSE 0 diff --git a/usr.orca.bin/udl/describe.udl b/usr.orca.bin/udl/describe.udl new file mode 100644 index 0000000..0b8b294 --- /dev/null +++ b/usr.orca.bin/udl/describe.udl @@ -0,0 +1,9 @@ +Name: udl +Version: 1.13 +Author: Soenke Behrens +Contact: soenke.behrens@conner.com +Where: /usr/local/bin +FTP: cco.caltech.edu, grind.isca.uiowa.edu + + Converts text between the CR, LF and CR/LF forms. Also available for +Unix machines, reasonably fast yet secure. diff --git a/usr.orca.bin/udl/udl.1 b/usr.orca.bin/udl/udl.1 index d03b388..4569ecd 100644 --- a/usr.orca.bin/udl/udl.1 +++ b/usr.orca.bin/udl/udl.1 @@ -1,6 +1,6 @@ .\" Copyright (c) 1993-1994 Soenke Behrens -.\" $Id: udl.1,v 1.1 1994/12/13 18:08:26 gdr Exp $ -.TH UDL 1 "22 November 1994" "Version 1.13" "Commands and Applications" +.\" $Id: udl.1,v 1.2 1995/02/08 05:05:42 gdr Exp $ +.TH UDL 1 "Commands and Applications" "22 November 1994" "Version 1.13" .SH NAME udl - convert text files between different architectures .SH SYNOPSIS @@ -16,10 +16,25 @@ udl - convert text files between different architectures .SH DESCRIPTION .B udl converts files between different computer systems by changing the EOL -(End-Of-Line) character. It does -.I not -do a plausability check, so the user has to make sure udl is not invoked -on object files or the like. +(End-Of-Line) character. +.PP +On the Apple IIgs, +.B udl +will skip any file that is not of type TXT or SRC. +No notice is given of this unless the +.B -v +flag is used. +Since Unix file systems do not have file types +.BR udl +is limited in the types of checks which it can carry out, +so the user must take care that +it is not invoked on object files or the like. On both platforms, if +.I file +appears to be a binary file (that is, no EOL is +found in the first part of the file), the file will be skipped. +Again, no notice is given of this unless the +.B -v +flag is used. .PP .B udl creates a temporary file the size of the file it is currently working on @@ -55,14 +70,6 @@ one file). For conversions to or from MS-DOS, .B udl is always pedantic, so this only affects conversions from Unix to Apple or vice versa. Being pedantic slows udl down by a factor of 1.5. -.PP -If -.B udl -is given a file that seems to be a binary file \(that is, no EOL is -found in the first part of the file\), the file will be skipped. No -notice is given of this unless the -.B -v -flag is used. .SH BUGS When compiling on some Solaris installations, files within subdirectories do not get their names properly resolved. @@ -71,6 +78,15 @@ This seems to be due to bad definitions in If you have access to SunOS 4.x, .BR udl can be compiled there and used under Solaris. +.PP +When running under Gno on the Apple IIgs, there is a limit to the nesting +depth when recusing on subdirectories. This is because the routine that +is responsible for this behavior is itself recursive. The default 2k +stack size will allow about 33 levels of nested directories, so this limit +should not normally be a problem. If the limit is exceeded, +.BR udl +will exit with an error message before any files are changed, and before +the stack actually overflows. .LP If you find any other bugs, please send a report to the address given below. .SH AUTHOR diff --git a/usr.orca.bin/udl/udlgs.c b/usr.orca.bin/udl/udlgs.c index aa584b1..029daa9 100644 --- a/usr.orca.bin/udl/udlgs.c +++ b/usr.orca.bin/udl/udlgs.c @@ -4,7 +4,7 @@ * * Apple IIgs specific routines. * - * $Id: udlgs.c,v 1.1 1994/12/13 18:08:29 gdr Exp $ + * $Id: udlgs.c,v 1.2 1995/02/08 05:05:46 gdr Exp $ * * Copyright (c) 1993-1994 Soenke Behrens */ @@ -18,6 +18,7 @@ #include "common.h" #define QUITFLAG 0x4000 /* udl is restartable */ +#define DIRECTORY 0x0F /* * Globals @@ -65,6 +66,7 @@ int main(int argc,char *argv[]) { pathSlots = 0; pathList = NULL; *currentDirectory = '\0'; + recursionDepth=0; #ifdef CHECK_STACK begin_stack_check(); @@ -79,7 +81,7 @@ int main(int argc,char *argv[]) { if (right_shell_version() == FALSE) { fprintf(stderr,"%s requires at least ORCA/Shell 2.0" - " or GNO/ME 1.0\n", argv[0]); + " or GNO/ME 1.0\n", argv[0]); exit (EXIT_FAILURE); } @@ -109,27 +111,27 @@ int main(int argc,char *argv[]) { case 'u': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not " - "specify more than one conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not " + "specify more than one conversion option\n",program_name); + exit (EXIT_FAILURE); } Tunix = TRUE; break; case 'm': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not " - "specify more than one conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not " + "specify more than one conversion option\n",program_name); + exit (EXIT_FAILURE); } Messy = TRUE; break; case 'g': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not " - "specify more than one conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not " + "specify more than one conversion option\n",program_name); + exit (EXIT_FAILURE); } GS = TRUE; break; @@ -156,7 +158,7 @@ int main(int argc,char *argv[]) { if (Tunix == FALSE && GS == FALSE && Messy == FALSE) { fprintf(stderr,"%s: You have to specify a destination " - "format.\n",program_name); + "format.\n",program_name); exit (EXIT_FAILURE); } @@ -177,7 +179,11 @@ int main(int argc,char *argv[]) { rsp.bufSize = 259; NextWild.pathName = &rsp; InitWild.wFile = &gsp; - InitWild.flags = 0x8000 | 0x2000 | 0x1000; + if (R_flag) { + InitWild.flags = 0x2000 | 0x1000; + } else { + InitWild.flags = 0; + } /* loop through all command line args */ for (; optind < argc; optind++) { @@ -192,33 +198,33 @@ int main(int argc,char *argv[]) { /* loop through all matches of wildcards */ for (;;) { - NextWildcardGS (&NextWild); - if (toolerror()) { - fprintf(stderr,"%s: Fatal internal error, " + NextWildcardGS (&NextWild); + if (toolerror()) { + fprintf(stderr,"%s: Fatal internal error, " "exiting\n", program_name); - exit (EXIT_FAILURE); - } - - /* No further file found by NextWildcardGS */ - if(!rsp.bufString.length) - break; - - num_of_files++; - - if((current_file = calloc(1,rsp.bufString.length + 1)) == NULL) { - fprintf(stderr,"%s: memory allocation failure\n",program_name); - exit (EXIT_FAILURE); - } - strncpy(current_file, rsp.bufString.text,rsp.bufString.length); - - add_to_pathList("",current_file); - free(current_file); - current_file = NULL; + exit (EXIT_FAILURE); + } + + /* No further file found by NextWildcardGS */ + if(!rsp.bufString.length) + break; + + num_of_files++; + + if((current_file = calloc(1,rsp.bufString.length + 1)) == NULL) { + fprintf(stderr,"%s: memory allocation failure\n",program_name); + exit (EXIT_FAILURE); + } + strncpy(current_file, rsp.bufString.text,rsp.bufString.length); + + add_to_pathList("",current_file); + free(current_file); + current_file = NULL; } /* for (;;) */ if (num_of_files == 0) - fprintf(stderr,"%s: No files found that match %s\n", - program_name,argv[optind]); + fprintf(stderr,"%s: No files found that match %s\n", + program_name,argv[optind]); } /* for (; optind < argc; optind++) */ } /* gsh or other Gno shell */ @@ -244,8 +250,6 @@ int main(int argc,char *argv[]) { current_file = *p; if (CheckGSOSType (current_file) == FALSE) { - fprintf(stderr,"%s: %s is not of type TXT or " - "SRC ... skipping\n",program_name,current_file); p++; continue; } @@ -260,18 +264,18 @@ int main(int argc,char *argv[]) { converted = TRUE; /* always */ if (GS) - convert_gs(infile,outfile); + convert_gs(infile,outfile); else if (Tunix) - convert_tunix(infile,outfile); + convert_tunix(infile,outfile); else - convert_messy(infile,outfile); + convert_messy(infile,outfile); } else { if (GS) - converted = convert_fast_gs(infile,outfile); + converted = convert_fast_gs(infile,outfile); else if (Tunix) - converted = convert_fast_tunix(infile,outfile); + converted = convert_fast_tunix(infile,outfile); else - converted = convert_fast_messy(infile,outfile); + converted = convert_fast_messy(infile,outfile); } if (fclose (infile) == EOF || fclose (outfile) == EOF) { @@ -281,14 +285,14 @@ int main(int argc,char *argv[]) { if (converted) { /* Temp file contains converted data */ if (remove (current_file) != 0) { - perror ("removing original file"); - exit (EXIT_FAILURE); + perror ("removing original file"); + exit (EXIT_FAILURE); } if (rename (tempfile,current_file) != 0) { - copy_file (tempfile,current_file); - remove (tempfile); - tempfile = NULL; + copy_file (tempfile,current_file); + remove (tempfile); + tempfile = NULL; } } else remove (tempfile); @@ -331,13 +335,16 @@ int CheckGSOSType(char *name) { if (toolerror()) { fprintf (stderr,"%s: GS/OS error on %s: 0x%04X\n", - program_name,name,toolerror()); + program_name,name,toolerror()); exit (EXIT_FAILURE); } - if ((fir.fileType != TXT) && (fir.fileType != SRC)) + if ((fir.fileType != TXT) && (fir.fileType != SRC)) { + if (verbose && (fir.fileType != DIRECTORY)) + fprintf(stderr,"%s: %s is not of type TXT or " + "SRC ... skipping\n",program_name,current_file); return (FALSE); - else { + } else { theType = fir.fileType; theAuxType = fir.auxType; return (TRUE); @@ -372,7 +379,7 @@ void SetGSOSType (char *name, int type, int auxtype) { if (toolerror()) { fprintf (stderr,"%s: GS/OS error on %s: 0x%04X\n", - program_name,name,toolerror()); + program_name,name,toolerror()); exit (EXIT_FAILURE); } } diff --git a/usr.orca.bin/udl/udlunix.c b/usr.orca.bin/udl/udlunix.c index fb4d503..dfde231 100644 --- a/usr.orca.bin/udl/udlunix.c +++ b/usr.orca.bin/udl/udlunix.c @@ -4,7 +4,7 @@ * * Unix specific routines. * - * $Id: udlunix.c,v 1.1 1994/12/13 18:08:32 gdr Exp $ + * $Id: udlunix.c,v 1.2 1995/02/08 05:05:48 gdr Exp $ * * Copyright (c) 1993-1994 Soenke Behrens */ @@ -33,6 +33,7 @@ int main(int argc,char *argv[]) { pathSlots = 0; pathList = NULL; *currentDirectory = '\0'; + recursionDepth=0; /* In case of exit(), free the mem I allocated */ #ifdef HAS_ATEXIT @@ -64,31 +65,31 @@ int main(int argc,char *argv[]) { case 'u': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not " - "specify more than one conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not " + "specify more than one conversion option\n",program_name); + exit (EXIT_FAILURE); } Tunix = TRUE; break; - + case 'm': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not specify more than one " - "conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not specify more than one " + "conversion option\n",program_name); + exit (EXIT_FAILURE); } Messy = TRUE; break; - + case 'g': if (Tunix == TRUE || Messy == TRUE || GS == TRUE) { - fprintf(stderr, "%s: You may not specify more than one " - "conversion option\n",program_name); - exit (EXIT_FAILURE); + fprintf(stderr, "%s: You may not specify more than one " + "conversion option\n",program_name); + exit (EXIT_FAILURE); } GS = TRUE; break; - + case 'R': R_flag++; break; @@ -96,7 +97,7 @@ int main(int argc,char *argv[]) { case '?': usage(); exit (EXIT_FAILURE); - + default: fprintf (stderr, "%s: Internal getopt error\n", program_name); exit (EXIT_FAILURE); @@ -112,7 +113,7 @@ int main(int argc,char *argv[]) { if (Tunix == FALSE && GS == FALSE && Messy == FALSE) { fprintf(stderr,"%s: You have to specify a destination " - "format.\n",program_name); + "format.\n",program_name); exit (EXIT_FAILURE); } @@ -152,7 +153,7 @@ int main(int argc,char *argv[]) { if (verbose == TRUE) { printf("%s: Working on %s\n",program_name, - current_file); + current_file); } infile = tryopen(current_file,"rwb"); @@ -162,18 +163,18 @@ int main(int argc,char *argv[]) { converted = TRUE; /* always */ if (GS) - convert_gs(infile,outfile); + convert_gs(infile,outfile); else if (Tunix) - convert_tunix(infile,outfile); + convert_tunix(infile,outfile); else - convert_messy(infile,outfile); + convert_messy(infile,outfile); } else { if (GS) - converted = convert_fast_gs(infile,outfile); + converted = convert_fast_gs(infile,outfile); else if (Tunix) - converted = convert_fast_tunix(infile,outfile); + converted = convert_fast_tunix(infile,outfile); else - converted = convert_fast_messy(infile,outfile); + converted = convert_fast_messy(infile,outfile); } if (fclose (infile) == EOF || fclose (outfile) == EOF) { @@ -183,14 +184,14 @@ int main(int argc,char *argv[]) { if (converted) { /* Temp file contains converted data */ if (remove (current_file) != 0) { - perror ("removing original file"); - exit (EXIT_FAILURE); + perror ("removing original file"); + exit (EXIT_FAILURE); } if (rename (tempfile,current_file) != 0) { - copy_file (tempfile,current_file); - remove (tempfile); - tempfile = NULL; + copy_file (tempfile,current_file); + remove (tempfile); + tempfile = NULL; } } else remove (tempfile); @@ -202,5 +203,3 @@ int main(int argc,char *argv[]) { return (EXIT_SUCCESS); } - - diff --git a/usr.orca.bin/udl/udluse.c b/usr.orca.bin/udl/udluse.c index 17d2dc8..0efdcbc 100644 --- a/usr.orca.bin/udl/udluse.c +++ b/usr.orca.bin/udl/udluse.c @@ -4,7 +4,7 @@ * * Usage strings. * - * $Id: udluse.c,v 1.1 1994/12/13 18:08:34 gdr Exp $ + * $Id: udluse.c,v 1.2 1995/02/08 05:05:49 gdr Exp $ * * Copyright (c) 1993-1994 Soenke Behrens */ @@ -23,7 +23,6 @@ char use1 [] = "written when it is done.\n"; char use2 [] = -"files may contain ORCA/Shell style wildcards.\n\n"; +"\nFiles may contain ORCA/Shell style wildcards.\n"; /* End Of File */ -