int
getline()
{
-register int i;
-
loop: if (incfil >= 0) {
if (fgets(ib, sizeof ib, ifp[incfil]) == NULL) {
fclose(ifp[incfil--]);
++srcline[cfile];
}
}
- i = strlen(ib) - 1;
- if (ib[i] == '\n')
- ib[i] = 0;
+ chop_crlf(ib);
return (1);
}
c = getnb();
return( (c == '\0' || c == ';') ? 0 : c );
}
+
+/*)Function VOID chop_crlf(str)
+ *
+ * char *str string to chop
+ *
+ * The function chop_crlf() removes trailing LF or CR/LF from
+ * str, if present.
+ *
+ * local variables:
+ * int i string length
+ *
+ * global variables:
+ * none
+ *
+ * functions called:
+ * none
+ *
+ * side effects:
+ * none
+ */
+
+VOID
+chop_crlf(str)
+char *str;
+{
+ register int i;
+
+ i = strlen(str);
+ if (i >= 1 && str[i-1] == '\n') str[i-1] = 0;
+ if (i >= 2 && str[i-2] == '\r') str[i-2] = 0;
+}
extern int more();
extern VOID skip();
extern VOID unget();
+extern VOID chop_crlf();
/* lkarea.c */
extern VOID lkparea();
extern VOID getst();
extern int more();
extern VOID unget();
+extern VOID chop_crlf();
/* assym.c */
extern struct area * alookup();
int
getline()
{
- register int i, ftype;
+ register int ftype;
register char *fid;
loop: if (pflag && cfp && cfp->f_type == F_STD)
return(0);
}
}
- i = strlen(ib) - 1;
- if (ib[i] == '\n')
- ib[i] = 0;
+ chop_crlf(ib);
return (1);
}
c = getnb();
return( (c == '\0' || c == ';') ? 0 : c );
}
+
+/*)Function VOID chop_crlf(str)
+ *
+ * char *str string to chop
+ *
+ * The function chop_crlf() removes trailing LF or CR/LF from
+ * str, if present.
+ *
+ * local variables:
+ * int i string length
+ *
+ * global variables:
+ * none
+ *
+ * functions called:
+ * none
+ *
+ * side effects:
+ * none
+ */
+
+VOID
+chop_crlf(str)
+char *str;
+{
+ register int i;
+
+ i = strlen(str);
+ if (i >= 1 && str[i-1] == '\n') str[i-1] = 0;
+ if (i >= 2 && str[i-2] == '\r') str[i-2] = 0;
+}
/*2*/ while (fgets(relfil, NINPUT, libfp) != NULL) {
relfil[NINPUT+1] = '\0';
- relfil[strlen(relfil) - 1] = '\0';
+ chop_crlf(relfil);
if (path != NULL) {
str = (char *) new (strlen(path)+strlen(relfil)+6);
strcpy(str,path);
/*4*/ while (fgets(buf, NINPUT, fp) != NULL) {
buf[NINPUT+1] = '\0';
- buf[strlen(buf) - 1] = '\0';
+ chop_crlf(buf);
/*
* Skip everything that's not a symbol record.
{
FILE *fp;
char str[NINPUT+2];
- int i;
if ((fp = fopen(filspc,"r")) != NULL) {
while (fgets(str, NINPUT, fp) != NULL) {
str[NINPUT+1] = '\0';
- i = strlen(str) - 1;
- if (str[i] == '\n')
- str[i] = '\0';
+ chop_crlf(str);
ip = str;
link_main();
}
i = strlen(ib) - 1;
if (ib[i] == '\n')
ib[i] = 0;
+ if (i >= 1 && ib[i-1] == '\r')
+ ib[i-1] = 0;
return (1);
}