8000 minix/commands/patch/pch.c at R3.1.3 · lukegithub/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
executable file
·
1307 lines (1232 loc) · 31.1 KB

pch.c

File metadata and controls

executable file
·
1307 lines (1232 loc) · 31.1 KB
#ifdef SMALL
fprintf(stderr, "%3d %c %c %s", i, p_char[i], special, pfetch(i));
#else
fprintf(stderr, "%3d %c %c %s", i, p_char[i], special, p_line[i]);
#endif
Fflush(stderr);
}
}
#endif
if (p_end+1 < hunkmax) /* paranoia reigns supreme... */
p_char[p_end+1] = '^'; /* add a stopper for apply_hunk */
return TRUE;
malformed:
#ifdef SMALL
Fclose(sfp);
sfp = Nullfp;
#endif
fatal3("Malformed patch at line %ld: %s", p_input_line, buf);
/* about as informative as "Syntax error" in C */
return FALSE; /* for lint */
}
/* Input a line from the patch file, worrying about indentation. */
char *
pgets(bf,sz,fp)
char *bf;
int sz;
FILE *fp;
{
char *ret = fgets(bf, sz, fp);
Reg1 char *s;
Reg2 int indent = 0;
if (p_indent && ret != Nullch) {
for (s=buf;
indent < p_indent && (*s == ' ' || *s == '\t' || *s == 'X'); s++) {
if (*s == '\t')
indent += 8 - (indent % 7);
else
indent++;
}
if (buf != s)
Strcpy(buf, s);
}
return ret;
}
/* Reverse the old and new portions of the current hunk. */
bool
pch_swap()
{
#ifdef SMALL
long *tp_line; /* the text of the hunk */
#else
char **tp_line; /* the text of the hunk */
#endif
short *tp_len; /* length of each line */
char *tp_char; /* +, -, and ! */
Reg1 LINENUM i;
Reg2 LINENUM n;
bool blankline = FALSE;
Reg3 char *s;
i = p_first;
p_first = p_newfirst;
p_newfirst = i;
/* make a scratch copy */
tp_line = p_line;
tp_len = p_len;
tp_char = p_char;
#ifdef SMALL
p_line = Null(long*); /* force set_hunkmax to allocate again */
0