Commit f9cf182e by Richard Kenner

(newline_fix, name_newline_fix): Don't treat \r specially here; it only causes bugs.

(newline_fix, name_newline_fix): Don't treat \r specially here; it
only causes bugs.  This undoes the May 14 16:01:13 1990 change to
newline_fix and name_newline_fix.

From-SVN: r8151
parent 1abe4c83
...@@ -2310,25 +2310,15 @@ newline_fix (bp) ...@@ -2310,25 +2310,15 @@ newline_fix (bp)
U_CHAR *bp; U_CHAR *bp;
{ {
register U_CHAR *p = bp; register U_CHAR *p = bp;
register int count = 0;
/* First count the backslash-newline pairs here. */ /* First count the backslash-newline pairs here. */
while (1) { while (p[0] == '\\' && p[1] == '\n')
if (p[0] == '\\') { p += 2;
if (p[1] == '\n')
p += 2, count++;
else if (p[1] == '\r' && p[2] == '\n')
p += 3, count++;
else
break;
} else
break;
}
/* What follows the backslash-newlines is not embarrassing. */ /* What follows the backslash-newlines is not embarrassing. */
if (count == 0 || (*p != '/' && *p != '*')) if (*p != '/' && *p != '*')
return; return;
/* Copy all potentially embarrassing characters /* Copy all potentially embarrassing characters
...@@ -2339,7 +2329,7 @@ newline_fix (bp) ...@@ -2339,7 +2329,7 @@ newline_fix (bp)
*bp++ = *p++; *bp++ = *p++;
/* Now write the same number of pairs after the embarrassing chars. */ /* Now write the same number of pairs after the embarrassing chars. */
while (count-- > 0) { while (bp < p) {
*bp++ = '\\'; *bp++ = '\\';
*bp++ = '\n'; *bp++ = '\n';
} }
...@@ -2353,24 +2343,14 @@ name_newline_fix (bp) ...@@ -2353,24 +2343,14 @@ name_newline_fix (bp)
U_CHAR *bp; U_CHAR *bp;
{ {
register U_CHAR *p = bp; register U_CHAR *p = bp;
register int count = 0;
/* First count the backslash-newline pairs here. */ /* First count the backslash-newline pairs here. */
while (1) { while (p[0] == '\\' && p[1] == '\n')
if (p[0] == '\\') { p += 2;
if (p[1] == '\n')
p += 2, count++;
else if (p[1] == '\r' && p[2] == '\n')
p += 3, count++;
else
break;
} else
break;
}
/* What follows the backslash-newlines is not embarrassing. */ /* What follows the backslash-newlines is not embarrassing. */
if (count == 0 || !is_idchar[*p]) if (!is_idchar[*p])
return; return;
/* Copy all potentially embarrassing characters /* Copy all potentially embarrassing characters
...@@ -2381,7 +2361,7 @@ name_newline_fix (bp) ...@@ -2381,7 +2361,7 @@ name_newline_fix (bp)
*bp++ = *p++; *bp++ = *p++;
/* Now write the same number of pairs after the embarrassing chars. */ /* Now write the same number of pairs after the embarrassing chars. */
while (count-- > 0) { while (bp < p) {
*bp++ = '\\'; *bp++ = '\\';
*bp++ = '\n'; *bp++ = '\n';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment