home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
editor
/
sed
/
patches.os2
< prev
next >
Wrap
Text File
|
1994-01-31
|
13KB
|
520 lines
diff -cb orig/glob.c ./glob.c
*** orig/glob.c Tue Mar 20 19:08:38 1990
--- ./glob.c Fri Dec 22 21:43:52 1989
***************
*** 27,37 ****
--- 27,41 ----
#define D_NAMLEN(d) strlen((d)->d_name)
#else /* not USGr3 */
#define D_NAMLEN(d) ((d)->d_namlen)
+ #ifdef MSDOS
+ #include "dir.h"
+ #else
#ifdef USG
#include "ndir.h" /* Get ndir.h from the Emacs distribution. */
#else /* not USG */
#include <sys/dir.h>
#endif /* USG */
+ #endif
#endif /* USGr3 */
#ifdef USG
***************
*** 40,47 ****
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
#define rindex strrchr
struct passwd *getpwent(), *getpwuid(), *getpwnam();
!
extern char *memcpy ();
#else /* not USG */
#include <strings.h>
--- 44,52 ----
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
#define rindex strrchr
struct passwd *getpwent(), *getpwuid(), *getpwnam();
! #ifndef MSDOS
extern char *memcpy ();
+ #endif
#else /* not USG */
#include <strings.h>
***************
*** 58,64 ****
--- 63,71 ----
#endif /* sparc. */
#endif /* GCC. */
+ #ifndef MSDOS
#include <pwd.h>
+ #endif
extern char *malloc (), *realloc ();
extern void free ();
***************
*** 410,415 ****
--- 417,423 ----
++filename;
}
+ #ifndef MSDOS
if (glob_tilde && *pathname == '~')
{
if (directory_len == 0)
***************
*** 455,461 ****
}
}
}
! else if (glob_pattern_p (directory_name))
{
/* If directory_name contains globbing characters, then we
have to expand the previous levels. Just recurse. */
--- 463,471 ----
}
}
}
! else
! #endif
! if (glob_pattern_p (directory_name))
{
/* If directory_name contains globbing characters, then we
have to expand the previous levels. Just recurse. */
diff -cb orig/regex.c ./regex.c
*** orig/regex.c Tue Mar 20 19:08:42 1990
--- ./regex.c Tue Mar 20 18:58:30 1990
***************
*** 55,60 ****
--- 55,65 ----
#endif
#endif
+ #ifdef MSDOS
+ #include <memory.h>
+ #include <malloc.h>
+ #endif
+
/*
* Define the syntax stuff, so we can do the \<...\> things.
*/
***************
*** 165,170 ****
--- 170,176 ----
#define PATUNFETCH p--
+ #ifndef MSDOS
#define EXTEND_BUFFER \
{ char *old_buffer = bufp->buffer; \
if (bufp->allocated == (1L<<16)) goto too_big; \
***************
*** 182,187 ****
--- 188,212 ----
if (pending_exact) \
pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
}
+ #else
+ #define EXTEND_BUFFER \
+ { char *old_buffer = bufp->buffer; \
+ if (bufp->allocated == (1L<<15)) goto too_big; \
+ bufp->allocated *= 2; \
+ if (bufp->allocated > (1L<<15)) bufp->allocated = (1L<<15); \
+ bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated); \
+ if (bufp->buffer == 0) \
+ goto memory_exhausted; \
+ b = (b - old_buffer) + bufp->buffer; \
+ if (fixup_jump) \
+ fixup_jump = (fixup_jump - old_buffer) + bufp->buffer; \
+ if (laststart) \
+ laststart = (laststart - old_buffer) + bufp->buffer; \
+ begalt = (begalt - old_buffer) + bufp->buffer; \
+ if (pending_exact) \
+ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
+ }
+ #endif
static int store_jump (), insert_jump ();
***************
*** 256,262 ****
#endif
#endif
! if (bufp->allocated == 0)
{
bufp->allocated = 28;
if (bufp->buffer)
--- 281,287 ----
#endif
#endif
! if (bufp->allocated < 10)
{
bufp->allocated = 28;
if (bufp->buffer)
diff -cb orig/sed.c ./sed.c
*** orig/sed.c Tue Mar 20 19:08:48 1990
--- ./sed.c Tue Mar 20 19:13:10 1990
***************
*** 296,302 ****
static char NO_ADDR[] = "Command doesn't take any addresses";
static char LINE_JUNK[] ="Extra characters after command";
static char BAD_EOF[] = "Unexpected End-of-file";
! static char USAGE[] = "Usage: %s [-n] [-e script...] [-f sfile...] [file...]\n";
static char NO_REGEX[] = "No previous regular expression";
/* Yes, the main program, which parses arguments, and does the right thing with them,
--- 296,302 ----
static char NO_ADDR[] = "Command doesn't take any addresses";
static char LINE_JUNK[] ="Extra characters after command";
static char BAD_EOF[] = "Unexpected End-of-file";
! static char USAGE[] = "Usage: %s [-n] [-e script...] [-f sfile...] [file...]";
static char NO_REGEX[] = "No previous regular expression";
/* Yes, the main program, which parses arguments, and does the right thing with them,
***************
*** 309,319 ****
struct sed_label *go,*lbl;
myname=argv[0];
while((opt=getopt(argc,argv,"ne:f:"))!=EOF) {
switch(opt) {
case 'n':
if(no_default_output)
! panic(USAGE);
no_default_output++;
break;
case 'e':
--- 309,322 ----
struct sed_label *go,*lbl;
myname=argv[0];
+ if ( argc == 1 )
+ usage();
+
while((opt=getopt(argc,argv,"ne:f:"))!=EOF) {
switch(opt) {
case 'n':
if(no_default_output)
! usage();
no_default_output++;
break;
case 'e':
***************
*** 328,334 ****
}
if(!compiled) {
if(argc<=optind)
! panic("No program to run\n");
compile_string(argv[optind]);
optind++;
}
--- 331,337 ----
}
if(!compiled) {
if(argc<=optind)
! panic("No program to run");
compile_string(argv[optind]);
optind++;
}
***************
*** 338,344 ****
if(!strcmp(lbl->name,go->name))
break;
if(!lbl)
! panic("Can't find label for jump to '%s'\n",go->name);
go->v->v[go->v_index].x.jump=lbl;
}
--- 341,347 ----
if(!strcmp(lbl->name,go->name))
break;
if(!lbl)
! panic("Can't find label for jump to '%s'",go->name);
go->v->v[go->v_index].x.jump=lbl;
}
***************
*** 396,402 ****
--- 399,432 ----
if(str[0]=='-' && str[1]=='\0')
prog_file=stdin;
else
+ #ifdef OS2
+ {
+ char fname[256];
+
+ _searchenv(str, "INIT", fname);
+ if ( fname[0] == 0 )
+ _searchenv(str, "PATH", fname);
+ if ( fname[0] == 0 )
+ strcpy(fname,str);
+
+ prog_file=ck_fopen(fname,"r");
+ }
+ #else
prog_file=ck_fopen(str,"r");
+ #endif
+
+ #ifdef OS2
+ if ( !isatty(fileno(prog_file)) )
+ {
+ char line[80];
+
+ fgets(line, sizeof(line), prog_file);
+
+ if ( strnicmp(line, "extproc ", 8) != 0 )
+ rewind(prog_file);
+ }
+ #endif
+
ch=getc(prog_file);
if(ch=='#') {
ch=getc(prog_file);
***************
*** 729,737 ****
char *why;
{
if(prog_line)
! fprintf(stderr,"%s: file %s line %d: %s\n",myname,prog_name,prog_line,why);
else
! fprintf(stderr,"%s: %s\n",myname,why);
exit(1);
}
--- 759,767 ----
char *why;
{
if(prog_line)
! fprintf(stderr,"\n%s: file %s line %d: %s\n",myname,prog_name,prog_line,why);
else
! fprintf(stderr,"\n%s: %s\n",myname,why);
exit(1);
}
***************
*** 935,941 ****
ptr=(errno>=0 && errno<sys_nerr) ? sys_errlist[errno] : "Unknown error code";
bad_input++;
! fprintf(stderr,"%s: can't read %s: %s\n",myname,name,ptr);
return;
}
--- 965,971 ----
ptr=(errno>=0 && errno<sys_nerr) ? sys_errlist[errno] : "Unknown error code";
bad_input++;
! fprintf(stderr,"\n%s: can't read %s: %s\n",myname,name,ptr);
return;
}
***************
*** 1126,1132 ****
width+=2;
break;
default:
! printf("/%02x",(*tmp)&0xFF);
width+=2;
break;
}
--- 1156,1162 ----
width+=2;
break;
default:
! printf("\\x%02x",(*tmp)&0xFF);
width+=2;
break;
}
***************
*** 1177,1183 ****
}
}
if(ferror(cur_cmd->x.io_file))
! panic("Read error on input file to 'r' command\n");
}
break;
--- 1207,1213 ----
}
}
if(ferror(cur_cmd->x.io_file))
! panic("Read error on input file to 'r' command");
}
break;
***************
*** 1306,1312 ****
break;
default:
! panic("INTERNAL ERROR: Bad cmd %c\n",cur_cmd->cmd);
}
if(end_cycle)
break;
--- 1336,1342 ----
break;
default:
! panic("INTERNAL ERROR: Bad cmd %c",cur_cmd->cmd);
}
if(end_cycle)
break;
***************
*** 1337,1343 ****
return (input_EOF) ? 1 : 0;
default:
! panic("INTERNAL ERROR: bad address type\n");
break;
}
return -1;
--- 1367,1373 ----
return (input_EOF) ? 1 : 0;
default:
! panic("INTERNAL ERROR: bad address type");
break;
}
return -1;
***************
*** 1491,1496 ****
--- 1521,1538 ----
/* These routines were written as part of a library (by me), but since most
people don't have the library, here they are. */
+ usage()
+ {
+ printf("\n%s\n\n", version_string);
+ printf(USAGE,myname);
+
+ printf("\n\n -n no default output"
+ "\n -e script read script as a sed command"
+ "\n -f file read sed commands contained in file\n");
+
+ exit(4);
+ }
+
#ifdef __STDC__
#include "stdarg.h"
***************
*** 1501,1507 ****
va_list iggy;
va_start(iggy,str);
! fprintf(stderr,"%s: ",myname);
#ifdef NO_VFPRINTF
_doprnt(str,&iggy,stderr);
#else
--- 1543,1549 ----
va_list iggy;
va_start(iggy,str);
! fprintf(stderr,"\n%s: ",myname);
#ifdef NO_VFPRINTF
_doprnt(str,&iggy,stderr);
#else
***************
*** 1522,1528 ****
va_list iggy;
va_start(iggy);
! fprintf(stderr,"%s: ",myname);
#ifdef NO_VFPRINTF
_doprnt(str,&iggy,stderr);
#else
--- 1564,1570 ----
va_list iggy;
va_start(iggy);
! fprintf(stderr,"\n%s: ",myname);
#ifdef NO_VFPRINTF
_doprnt(str,&iggy,stderr);
#else
***************
*** 1572,1578 ****
ret=fopen(name,mode);
if(ret==(FILE *)0)
! panic("Couldn't open file %s\n",name);
for(n=0;n<N_FILE;n++) {
if(ret==__id_s[n].fp) {
free((VOID *)__id_s[n].name);
--- 1614,1620 ----
ret=fopen(name,mode);
if(ret==(FILE *)0)
! panic("Couldn't open file %s",name);
for(n=0;n<N_FILE;n++) {
if(ret==__id_s[n].fp) {
free((VOID *)__id_s[n].name);
***************
*** 1586,1592 ****
if(__id_s[n].fp==(FILE *)0)
break;
if(n==N_FILE)
! panic("Internal error: too many files open\n");
__id_s[n].fp=ret;
__id_s[n].name=(char *)ck_malloc(strlen(name)+1);
strcpy(__id_s[n].name,name);
--- 1628,1634 ----
if(__id_s[n].fp==(FILE *)0)
break;
if(n==N_FILE)
! panic("Internal error: too many files open");
__id_s[n].fp=ret;
__id_s[n].name=(char *)ck_malloc(strlen(name)+1);
strcpy(__id_s[n].name,name);
***************
*** 1611,1617 ****
FILE *stream;
{
if(fclose(stream)==EOF)
! panic("Couldn't close %s\n",__fp_name(stream));
}
/* Panic on failing malloc */
--- 1653,1659 ----
FILE *stream;
{
if(fclose(stream)==EOF)
! panic("Couldn't close %s",__fp_name(stream));
}
/* Panic on failing malloc */
***************
*** 1624,1630 ****
ret=malloc(size);
if(ret==(VOID *)0)
! panic("Couldn't allocate memory\n");
return ret;
}
--- 1666,1672 ----
ret=malloc(size);
if(ret==(VOID *)0)
! panic("Couldn't allocate memory");
return ret;
}
***************
*** 1639,1645 ****
ret=realloc(ptr,size);
if(ret==(VOID *)0)
! panic("Couldn't re-allocate memory\n");
return ret;
}
--- 1681,1687 ----
ret=realloc(ptr,size);
if(ret==(VOID *)0)
! panic("Couldn't re-allocate memory");
return ret;
}