removed some blank lines to make code count 700 lines
This commit is contained in:
parent
a763bd8c65
commit
1d945d0390
30
zep.c
30
zep.c
@ -49,11 +49,10 @@ typedef struct buffer_t
|
|||||||
} buffer_t;
|
} buffer_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some compilers define size_t as a unsigned 16 bit number while
|
* Some compilers define size_t as a unsigned 16 bit number while point_t and
|
||||||
* point_t and off_t might be defined as a signed 32 bit number.
|
* off_t might be defined as a signed 32 bit number. malloc(), realloc(),
|
||||||
* malloc(), realloc(), fread(), and fwrite() take size_t parameters,
|
* fread(), and fwrite() take size_t parameters, which means there will be some
|
||||||
* which means there will be some size limits because size_t is too
|
* size limits because size_t is too small of a type.
|
||||||
* small of a type.
|
|
||||||
*/
|
*/
|
||||||
#define MAX_SIZE_T ((unsigned long) (size_t) ~0)
|
#define MAX_SIZE_T ((unsigned long) (size_t) ~0)
|
||||||
|
|
||||||
@ -73,6 +72,7 @@ buffer_t* new_buffer()
|
|||||||
buffer_t *bp = (buffer_t *)malloc(sizeof(buffer_t));
|
buffer_t *bp = (buffer_t *)malloc(sizeof(buffer_t));
|
||||||
assert(bp != NULL);
|
assert(bp != NULL);
|
||||||
bp->b_point = 0;
|
bp->b_point = 0;
|
||||||
|
bp->b_mark = NOMARK;
|
||||||
bp->b_page = 0;
|
bp->b_page = 0;
|
||||||
bp->b_epage = 0;
|
bp->b_epage = 0;
|
||||||
bp->b_modified = 0;
|
bp->b_modified = 0;
|
||||||
@ -177,7 +177,6 @@ void save()
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
point_t length;
|
point_t length;
|
||||||
|
|
||||||
fp = fopen(curbp->b_fname, "w");
|
fp = fopen(curbp->b_fname, "w");
|
||||||
if (fp == NULL) msg("Failed to open file \"%s\".", curbp->b_fname);
|
if (fp == NULL) msg("Failed to open file \"%s\".", curbp->b_fname);
|
||||||
(void) movegap(curbp, (point_t) 0);
|
(void) movegap(curbp, (point_t) 0);
|
||||||
@ -201,10 +200,8 @@ int insert_file(char *fn)
|
|||||||
if (curbp->b_egap - curbp->b_gap < sb.st_size * sizeof (char_t) && !growgap(curbp, sb.st_size))
|
if (curbp->b_egap - curbp->b_gap < sb.st_size * sizeof (char_t) && !growgap(curbp, sb.st_size))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
if ((fp = fopen(fn, "r")) == NULL) return msg("Failed to open file \"%s\".", fn);
|
if ((fp = fopen(fn, "r")) == NULL) return msg("Failed to open file \"%s\".", fn);
|
||||||
|
|
||||||
curbp->b_point = movegap(curbp, curbp->b_point);
|
curbp->b_point = movegap(curbp, curbp->b_point);
|
||||||
curbp->b_gap += len = fread(curbp->b_gap, sizeof (char), (size_t) sb.st_size, fp);
|
curbp->b_gap += len = fread(curbp->b_gap, sizeof (char), (size_t) sb.st_size, fp);
|
||||||
|
|
||||||
if (fclose(fp) != 0) return msg("Failed to close file \"%s\".", fn);
|
if (fclose(fp) != 0) return msg("Failed to close file \"%s\".", fn);
|
||||||
msg("File \"%s\" %ld bytes read.", fn, len);
|
msg("File \"%s\" %ld bytes read.", fn, len);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -223,13 +220,11 @@ char_t *get_key(keymap_t *keys, keymap_t **key_return)
|
|||||||
*key_return = NULL;
|
*key_return = NULL;
|
||||||
return record++;
|
return record++;
|
||||||
}
|
}
|
||||||
/* reset record buffer. */
|
|
||||||
record = buffer;
|
record = buffer; /* reset record buffer. */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
assert(K_BUFFER_LENGTH > record - buffer);
|
assert(K_BUFFER_LENGTH > record - buffer);
|
||||||
/* read and record one byte. */
|
*record++ = (unsigned)getch(); /* read and record one byte. */
|
||||||
*record++ = (unsigned)getch();
|
|
||||||
*record = '\0';
|
*record = '\0';
|
||||||
|
|
||||||
/* if recorded bytes match any multi-byte sequence... */
|
/* if recorded bytes match any multi-byte sequence... */
|
||||||
@ -245,9 +240,7 @@ char_t *get_key(keymap_t *keys, keymap_t **key_return)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* record bytes match part of a command sequence */
|
/* record bytes match part of a command sequence */
|
||||||
if (*p == '\0' && *q != '\0') {
|
if (*p == '\0' && *q != '\0') submatch = 1;
|
||||||
submatch = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (submatch);
|
} while (submatch);
|
||||||
/* nothing matched, return recorded bytes. */
|
/* nothing matched, return recorded bytes. */
|
||||||
@ -567,13 +560,11 @@ point_t search_forward(buffer_t *bp, point_t start_p, char *stext)
|
|||||||
point_t p,pp;
|
point_t p,pp;
|
||||||
char* s;
|
char* s;
|
||||||
|
|
||||||
if (0 == strlen(stext))
|
if (0 == strlen(stext)) return start_p;
|
||||||
return start_p;
|
|
||||||
|
|
||||||
for (p=start_p; p < end_p; p++) {
|
for (p=start_p; p < end_p; p++) {
|
||||||
for (s=stext, pp=p; *s == *(ptr(bp, pp)) && *s !='\0' && pp < end_p; s++, pp++)
|
for (s=stext, pp=p; *s == *(ptr(bp, pp)) && *s !='\0' && pp < end_p; s++, pp++)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (*s == '\0') return pp;
|
if (*s == '\0') return pp;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -677,7 +668,6 @@ keymap_t keymap[] = {
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2) fatal("usage: " E_NAME " filename\n");
|
if (argc != 2) fatal("usage: " E_NAME " filename\n");
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
raw();
|
raw();
|
||||||
noecho();
|
noecho();
|
||||||
|
Loading…
Reference in New Issue
Block a user