home *** CD-ROM | disk | FTP | other *** search
- diff -C 3 emacs-18.58/cpp/cccp.c gnuemacs:cpp/cccp.c
- *** emacs-18.58/cpp/cccp.c Sun May 03 14:46:13 1992
- --- gnuemacs:cpp/cccp.c Sun May 03 14:34:10 1992
- ***************
- *** 97,103 ****
- --- 97,116 ----
-
- #ifdef EMACS
- #define NO_SHORTNAMES
- + #ifdef AMIGA
- + #include "/src/config.h"
- + #undef free
- + #undef malloc
- + #undef calloc
- + #undef realloc
- + #undef fflush
- + #undef fwrite
- + #define fflush(fp) _flsbf(-1,fp)
- + #define rindex strrchr
- + #undef AMIGA_DUMP
- + #else
- #include "../src/config.h"
- + #endif
- #ifdef static
- #undef static
- #endif
- ***************
- *** 115,121 ****
- --- 128,138 ----
- #include <ctype.h>
- #include <stdio.h>
- #ifndef USG
- + #ifdef AMIGA
- + #include <time.h>
- + #else
- #include <sys/time.h> /* for __DATE__ and __TIME__ */
- + #endif
- #else
- #define index strchr
- #define rindex strrchr
- ***************
- *** 123,130 ****
- --- 140,149 ----
- #include <fcntl.h>
- #endif /* USG */
-
- + #ifndef AMIGA
- void bcopy (), bzero ();
- int bcmp ();
- + #endif
-
- char *xmalloc (), *xrealloc (), *xcalloc ();
- void fatal (), pfatal_with_name (), perror_with_name ();
- ***************
- *** 142,156 ****
- --- 161,189 ----
- /* #include "file" starts with the first entry in the stack */
- /* #include <file> starts with the second. */
- /* -I directories are added after the first */
- + #ifdef AMIGA
- struct directory_stack default_includes[2] =
- {
- + { &default_includes[1], "" },
- + { 0, "cpp-include:" }
- + };
- + #else
- + struct directory_stack default_includes[2] =
- + {
- { &default_includes[1], "." },
- { 0, "/usr/include" }
- };
- + #endif
- +
- struct directory_stack *include = &default_includes[0];
-
- + #ifdef AMIGA
- int max_include_len = 14; /* strlen (default_include) + 2
- (for / and null) */
- + #else
- + int max_include_len = 9; /* strlen (default_include) + 1
- + (for null) */
- + #endif
-
- char STDIN_FILE[] = ""; /* Empty, like real cpp */
- int put_out_comments = 0; /* JF non-zero means leave comments in the
- ***************
- *** 379,385 ****
- dirtmp->next = include->next;
- include->next = dirtmp;
- dirtmp->fname = argv[i]+2;
- - include = dirtmp;
- if (strlen (argv[i]) > max_include_len)
- max_include_len = strlen (argv[i]);
- break;
- --- 412,417 ----
- ***************
- *** 405,411 ****
- --- 437,447 ----
- else if ((f = open (in_fname, O_RDONLY)) < 0)
- goto perror;
-
- + #ifdef AMIGA
- + stat (in_fname, &sbuf);
- + #else
- fstat (f, &sbuf);
- + #endif
- fp->fname = in_fname;
- fp->lineno = 1;
- /* JF all this is mine about reading pipes and ttys */
- ***************
- *** 652,658 ****
- register U_CHAR *p = hp->name;
- register U_CHAR *q = op->bufp - i;
-
- ! if (c != (U_CHAR) -1)
- q--;
-
- do { /* all this to avoid a strncmp() */
- --- 688,694 ----
- register U_CHAR *p = hp->name;
- register U_CHAR *q = op->bufp - i;
-
- ! if (c != -1)
- q--;
-
- do { /* all this to avoid a strncmp() */
- ***************
- *** 663,669 ****
- save_ibufp = ip->bufp;
- /* back up over identifier, then expand token */
- op->bufp -= ident_length;
- ! if (c != (U_CHAR) -1) op->bufp--;
- macroexpand (hp, ip, op, &excess_newlines);
-
- check_expand(op, ip->length - (ip->bufp - ip->buf));
- --- 699,705 ----
- save_ibufp = ip->bufp;
- /* back up over identifier, then expand token */
- op->bufp -= ident_length;
- ! if (c != -1) op->bufp--;
- macroexpand (hp, ip, op, &excess_newlines);
-
- check_expand(op, ip->length - (ip->bufp - ip->buf));
- ***************
- *** 670,676 ****
-
- /* If we just processed an identifier at end of input,
- return right away. */
- ! if (c == (U_CHAR) -1)
- return;
-
- /* if the expansion routine has not moved the input
- --- 706,712 ----
-
- /* If we just processed an identifier at end of input,
- return right away. */
- ! if (c == -1)
- return;
-
- /* if the expansion routine has not moved the input
- ***************
- *** 978,984 ****
- struct stat sbuf; /* to stat the include file */
- FILE_BUF *fp; /* for input stack frame */
- struct directory_stack *stackp;
- ! int flen;
-
- int save_indepth = indepth;
- /* in case of errors */
- --- 1014,1020 ----
- struct stat sbuf; /* to stat the include file */
- FILE_BUF *fp; /* for input stack frame */
- struct directory_stack *stackp;
- ! int flen, maxlen;
-
- int save_indepth = indepth;
- /* in case of errors */
- ***************
- *** 1019,1025 ****
- --- 1055,1064 ----
- if (err)
- goto nope;
-
- + /* DG: This doesn't handle includes of aa:... on the Amiga */
- + /* It doesn't seem worth it. */
- other_dir = NULL;
- + maxlen = max_include_len;
- if (stackp == include)
- {
- fp = &instack[indepth];
- ***************
- *** 1037,1042 ****
- --- 1076,1082 ----
- other_dir = (char *) alloca (n + 1);
- strncpy (other_dir, nam, n);
- other_dir[n] = '\0';
- + if (n + 4 > maxlen) maxlen = n + 4;
- }
- break;
- }
- ***************
- *** 1043,1049 ****
- }
- }
- /* JF search directory path */
- ! fname = (char *) alloca (max_include_len + flen);
- for (; stackp; stackp = stackp->next)
- {
- if (other_dir)
- --- 1083,1089 ----
- }
- }
- /* JF search directory path */
- ! fname = (char *) alloca (maxlen + flen);
- for (; stackp; stackp = stackp->next)
- {
- if (other_dir)
- ***************
- *** 1053,1058 ****
- --- 1093,1102 ----
- }
- else
- strcpy (fname, stackp->fname);
- + #ifdef AMIGA
- + if (fname[0] != 0 && fname[strlen(fname) - 1] != ':')
- + /* Don't add / after : or empty strings */
- + #endif
- strcat (fname, "/");
- strncat (fname, fbeg, flen);
- if ((f = open (fname, O_RDONLY)) >= 0)
- ***************
- *** 1064,1070 ****
- --- 1108,1118 ----
- goto nope;
- }
-
- + #ifdef AMIGA
- + if (stat(fname, &sbuf) < 0)
- + #else
- if (fstat(f, &sbuf) < 0)
- + #endif
- {
- perror_with_name (fname);
- goto nope; /* impossible? */
- ***************
- *** 1308,1314 ****
-
- if (is_idstart[*p] && (p==buf || !is_idchar[*(p-1)])) {
-
- ! for (id_len = 0; is_idchar[p[id_len]]; id_len++)
- ;
- for (arg = arglist; arg != NULL; arg = arg->next) {
- struct reflist *tpat;
- --- 1356,1362 ----
-
- if (is_idstart[*p] && (p==buf || !is_idchar[*(p-1)])) {
-
- ! for (id_len = 0; p+id_len < buf+size && is_idchar[p[id_len]]; id_len++)
- ;
- for (arg = arglist; arg != NULL; arg = arg->next) {
- struct reflist *tpat;
- ***************
- *** 1465,1470 ****
- --- 1513,1533 ----
- * the behavior of the #pragma directive is implementation defined.
- * this implementation defines it as follows.
- */
- + #ifdef AMIGA
- + do_pragma(buf, limit, op, keyword)
- + U_CHAR *buf, *limit;
- + FILE_BUF *op;
- + struct keyword_table *keyword;
- + {
- + /* Just copy the pragma directibe back out */
- + int len2 = limit - buf, len1 = sizeof("#pragma") - 1;
- +
- + check_expand(op, len1 + len2);
- + bcopy("#pragma", op->bufp, len1);
- + bcopy(buf, op->bufp + len1, len2);
- + op->bufp += len1 + len2;
- + }
- + #else
- do_pragma()
- {
- close (0);
- ***************
- *** 1479,1484 ****
- --- 1542,1548 ----
- nope:
- fatal ("You are in a maze of twisty compiler features, all different");
- }
- + #endif
-
- typedef struct if_stack {
- struct if_stack *next; /* for chaining to the next stack frame */
- ***************
- *** 2084,2092 ****
- }
-
- if (ip != NULL)
- ! fprintf(stdout, "file %s, offset %d (line %d): ",
- ip->fname, ip->bufp - ip->buf, ip->lineno);
- ! fprintf(stdout, "%s\n", msg);
- return 0;
- }
-
- --- 2148,2156 ----
- }
-
- if (ip != NULL)
- ! fprintf(stderr, "file %s, offset %d (line %d): ",
- ip->fname, ip->bufp - ip->buf, ip->lineno);
- ! fprintf(stderr, "%s\n", msg);
- return 0;
- }
-
-