mirror of
https://github.com/fachat/xa65.git
synced 2024-06-17 04:29:48 +00:00
simpler forced newline at end of file
This commit is contained in:
parent
46ba1dbeb3
commit
34c9f0bcea
51
xa/src/xap.c
51
xa/src/xap.c
|
@ -950,36 +950,6 @@ int pgetline(char *t)
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/* this is the most disgusting code I have ever written, but Andre drove me
|
|
||||||
to it because I can't think of any other F$%Y#*U(%&Y##^#KING way to fix the
|
|
||||||
last line bug ... a very irritated Cameron */
|
|
||||||
|
|
||||||
/* however, it also solved the problem of open #ifdefs not bugging out */
|
|
||||||
|
|
||||||
/* #define DEBUG_EGETC */
|
|
||||||
int egetc(FILE *fp) {
|
|
||||||
int c;
|
|
||||||
static int ungeteof = 0;
|
|
||||||
|
|
||||||
c = getc(fp);
|
|
||||||
if (c == EOF) {
|
|
||||||
if (ungeteof) {
|
|
||||||
#ifdef DEBUG_EGETC
|
|
||||||
fprintf(stderr, "eof claimed\n");
|
|
||||||
#endif
|
|
||||||
return c;
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUG_EGETC
|
|
||||||
fprintf(stderr, "got eof!!\n");
|
|
||||||
#endif
|
|
||||||
ungeteof = 1;
|
|
||||||
return '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ungeteof = 0;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* smart getc that can skip C comment blocks */
|
/* smart getc that can skip C comment blocks */
|
||||||
int rgetc(FILE *fp)
|
int rgetc(FILE *fp)
|
||||||
{
|
{
|
||||||
|
@ -1000,10 +970,10 @@ int rgetc(FILE *fp)
|
||||||
c = d;
|
c = d;
|
||||||
d_isvalid = 0;
|
d_isvalid = 0;
|
||||||
} else {
|
} else {
|
||||||
c = egetc(fp);
|
c = getc(fp);
|
||||||
}
|
}
|
||||||
while(c==13) {
|
while(c==13) {
|
||||||
c = egetc(fp);
|
c = getc(fp);
|
||||||
}; /* remove ^M for unices */
|
}; /* remove ^M for unices */
|
||||||
|
|
||||||
/* a newlinebreaks any quote */
|
/* a newlinebreaks any quote */
|
||||||
|
@ -1017,12 +987,12 @@ int rgetc(FILE *fp)
|
||||||
/* check for start of comment anyway, to allow for nestesd comments */
|
/* check for start of comment anyway, to allow for nestesd comments */
|
||||||
if(!inquote && c=='/')
|
if(!inquote && c=='/')
|
||||||
{
|
{
|
||||||
d = egetc(fp);
|
d = getc(fp);
|
||||||
|
|
||||||
// C++ double slash comment
|
// C++ double slash comment
|
||||||
if (d == '/') {
|
if (d == '/') {
|
||||||
do {
|
do {
|
||||||
c = egetc(fp);
|
c = getc(fp);
|
||||||
} while (c != '\n' && c != EOF);
|
} while (c != '\n' && c != EOF);
|
||||||
} else
|
} else
|
||||||
if (d == '*') {
|
if (d == '*') {
|
||||||
|
@ -1077,7 +1047,7 @@ int rgetc(FILE *fp)
|
||||||
/* note: incomment only set true if not quoted, and quote not changed in comment */
|
/* note: incomment only set true if not quoted, and quote not changed in comment */
|
||||||
if((!inquote) && (c=='*'))
|
if((!inquote) && (c=='*'))
|
||||||
{
|
{
|
||||||
if((d=egetc(fp))!='/') {
|
if((d=getc(fp))!='/') {
|
||||||
d_isvalid = 1;
|
d_isvalid = 1;
|
||||||
} else {
|
} else {
|
||||||
incomment--;
|
incomment--;
|
||||||
|
@ -1087,12 +1057,17 @@ int rgetc(FILE *fp)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
last = c;
|
/* force newline at the end of a file */
|
||||||
|
if (c == EOF && last != EOF) {
|
||||||
|
last = EOF;
|
||||||
|
c = '\n';
|
||||||
|
} else {
|
||||||
|
last = c;
|
||||||
|
}
|
||||||
|
|
||||||
} while(incomment && (c!=EOF));
|
} while(incomment && (c!=EOF));
|
||||||
|
|
||||||
|
|
||||||
return(c-'\t'?c:' ');
|
return(c-'\t'?c:' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user