conversion from 8 spaces to 4 spaces per tab

This commit is contained in:
Andreas Steffen
2009-04-19 19:16:09 +00:00
parent d940c7638c
commit 3d7a244b54
138 changed files with 47306 additions and 47306 deletions
+127 -127
View File
@@ -27,7 +27,7 @@
#include "constants.h"
#include "defs.h"
#include "log.h"
#include "whack.h" /* for RC_LOG_SERIOUS */
#include "whack.h" /* for RC_LOG_SERIOUS */
#include "lex.h"
struct file_lex_position *flp = NULL;
@@ -39,36 +39,36 @@ struct file_lex_position *flp = NULL;
bool
lexopen(struct file_lex_position *new_flp, const char *name, bool optional)
{
FILE *f = fopen(name, "r");
FILE *f = fopen(name, "r");
if (f == NULL)
{
if (!optional || errno != ENOENT)
log_errno((e, "could not open \"%s\"", name));
return FALSE;
}
else
{
new_flp->previous = flp;
flp = new_flp;
flp->filename = name;
flp->fp = f;
flp->lino = 0;
flp->bdry = B_none;
if (f == NULL)
{
if (!optional || errno != ENOENT)
log_errno((e, "could not open \"%s\"", name));
return FALSE;
}
else
{
new_flp->previous = flp;
flp = new_flp;
flp->filename = name;
flp->fp = f;
flp->lino = 0;
flp->bdry = B_none;
flp->cur = flp->buffer; /* nothing loaded yet */
flp->under = *flp->cur = '\0';
flp->cur = flp->buffer; /* nothing loaded yet */
flp->under = *flp->cur = '\0';
(void) shift(); /* prime tok */
return TRUE;
}
(void) shift(); /* prime tok */
return TRUE;
}
}
void
lexclose(void)
{
fclose(flp->fp);
flp = flp->previous;
fclose(flp->fp);
flp = flp->previous;
}
/* Token decoding: shift() loads the next token into tok.
@@ -88,110 +88,110 @@ char *tok;
bool
shift(void)
{
char *p = flp->cur;
char *sor = NULL; /* start of record for any new lines */
char *p = flp->cur;
char *sor = NULL; /* start of record for any new lines */
passert(flp->bdry == B_none);
passert(flp->bdry == B_none);
*p = flp->under;
flp->under = '\0';
*p = flp->under;
flp->under = '\0';
for (;;)
{
switch (*p)
for (;;)
{
case '\0': /* end of line */
case '#': /* comment to end of line: treat as end of line */
/* get the next line */
if (fgets(flp->buffer, sizeof(flp->buffer)-1, flp->fp) == NULL)
{
flp->bdry = B_file;
tok = flp->cur = NULL;
return FALSE;
}
else
{
/* strip trailing whitespace, including \n */
for (p = flp->buffer+strlen(flp->buffer)-1
; p>flp->buffer && isspace(p[-1]); p--)
;
*p = '\0';
flp->lino++;
sor = p = flp->buffer;
}
break; /* try again for a token */
case ' ': /* whitespace */
case '\t':
p++;
break; /* try again for a token */
case '"': /* quoted token */
case '\'':
if (p != sor)
{
/* we have a quoted token: note and advance to its end */
tok = p;
p = strchr(p+1, *p);
if (p == NULL)
switch (*p)
{
loglog(RC_LOG_SERIOUS, "\"%s\" line %d: unterminated string"
, flp->filename, flp->lino);
p = tok + strlen(tok);
}
else
{
p++; /* include delimiter in token */
}
case '\0': /* end of line */
case '#': /* comment to end of line: treat as end of line */
/* get the next line */
if (fgets(flp->buffer, sizeof(flp->buffer)-1, flp->fp) == NULL)
{
flp->bdry = B_file;
tok = flp->cur = NULL;
return FALSE;
}
else
{
/* strip trailing whitespace, including \n */
/* remember token delimiter and replace with '\0' */
flp->under = *p;
*p = '\0';
flp->cur = p;
return TRUE;
}
/* FALL THROUGH */
default:
if (p != sor)
{
/* we seem to have a token: note and advance to its end */
tok = p;
for (p = flp->buffer+strlen(flp->buffer)-1
; p>flp->buffer && isspace(p[-1]); p--)
;
*p = '\0';
if (p[0] == '0' && p[1] == 't')
{
/* 0t... token goes to end of line */
p += strlen(p);
}
else
{
/* "ordinary" token: up to whitespace or end of line */
do {
flp->lino++;
sor = p = flp->buffer;
}
break; /* try again for a token */
case ' ': /* whitespace */
case '\t':
p++;
} while (*p != '\0' && !isspace(*p))
;
break; /* try again for a token */
/* fudge to separate ':' from a preceding adjacent token */
if (p-1 > tok && p[-1] == ':')
p--;
case '"': /* quoted token */
case '\'':
if (p != sor)
{
/* we have a quoted token: note and advance to its end */
tok = p;
p = strchr(p+1, *p);
if (p == NULL)
{
loglog(RC_LOG_SERIOUS, "\"%s\" line %d: unterminated string"
, flp->filename, flp->lino);
p = tok + strlen(tok);
}
else
{
p++; /* include delimiter in token */
}
/* remember token delimiter and replace with '\0' */
flp->under = *p;
*p = '\0';
flp->cur = p;
return TRUE;
}
/* FALL THROUGH */
default:
if (p != sor)
{
/* we seem to have a token: note and advance to its end */
tok = p;
if (p[0] == '0' && p[1] == 't')
{
/* 0t... token goes to end of line */
p += strlen(p);
}
else
{
/* "ordinary" token: up to whitespace or end of line */
do {
p++;
} while (*p != '\0' && !isspace(*p))
;
/* fudge to separate ':' from a preceding adjacent token */
if (p-1 > tok && p[-1] == ':')
p--;
}
/* remember token delimiter and replace with '\0' */
flp->under = *p;
*p = '\0';
flp->cur = p;
return TRUE;
}
/* we have a start-of-record: return it, deferring "real" token */
flp->bdry = B_record;
tok = NULL;
flp->under = *p;
flp->cur = p;
return FALSE;
}
/* remember token delimiter and replace with '\0' */
flp->under = *p;
*p = '\0';
flp->cur = p;
return TRUE;
}
/* we have a start-of-record: return it, deferring "real" token */
flp->bdry = B_record;
tok = NULL;
flp->under = *p;
flp->cur = p;
return FALSE;
}
}
}
/* ensures we are at a Record (or File) boundary, optionally warning if not */
@@ -199,15 +199,15 @@ shift(void)
bool
flushline(const char *m)
{
if (flp->bdry != B_none)
{
return TRUE;
}
else
{
if (m != NULL)
loglog(RC_LOG_SERIOUS, "\"%s\" line %d: %s", flp->filename, flp->lino, m);
do ; while (shift());
return FALSE;
}
if (flp->bdry != B_none)
{
return TRUE;
}
else
{
if (m != NULL)
loglog(RC_LOG_SERIOUS, "\"%s\" line %d: %s", flp->filename, flp->lino, m);
do ; while (shift());
return FALSE;
}
}