Repository navigation
Expand file tree
/
Copy pathbuffer.c
More file actions
88 lines (80 loc) · 2.18 KB
/
Copy pathbuffer.c
File metadata and controls
88 lines (80 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include "buffer.h"
#ifndef TRUE
#define TRUE 1
#endif
/* resize the line to length + factor */
ee_char *resiz_line(int factor, struct text *rline, int rpos)
{
ee_char *rpoint;
int resiz_var;
rline->max_length += factor;
rpoint = rline->line = realloc(rline->line, rline->max_length * sizeof(ee_char));
for (resiz_var = 1 ; (resiz_var < rpos) ; resiz_var++)
rpoint++;
return rpoint;
}
/* allocate space for line structure */
struct text *txtalloc(void)
{
struct text *t = malloc(sizeof(struct text));
if (!t) {
perror("malloc");
exit(1);
}
return t;
}
/* allocate space for file name list node */
struct files *name_alloc(void)
{
struct files *f = malloc(sizeof(struct files));
if (!f) {
perror("malloc");
exit(1);
}
return f;
}
/* move to next word in string */
ee_char *next_word(ee_char *string)
{
while ((*string != '\0') && ((*string != 32) && (*string != 9)))
string++;
while ((*string != '\0') && ((*string == 32) || (*string == 9)))
string++;
return string;
}
/* move to next word in an ASCII string */
char *next_ascii_word(char *string)
{
while ((*string != '\0') && ((*string != ' ') && (*string != '\t')))
string++;
while ((*string != '\0') && ((*string == ' ') || (*string == '\t')))
string++;
return string;
}
/* move to start of previous word in text */
void prev_word(void)
{
extern int position; /* globals from ee.c */
extern ee_char *point;
void left(int disp); /* functions still in ee.c */
void right(int disp);
if (position != 1)
{
if ((position != 1) && ((point[-1] == ' ') || (point[-1] == '\t')))
{
while ((position != 1) && ((*point != ' ') && (*point != '\t')))
left(TRUE);
}
while ((position != 1) && ((*point == ' ') || (*point == '\t')))
left(TRUE);
while ((position != 1) && ((*point != ' ') && (*point != '\t')))
left(TRUE);
if ((position != 1) && ((*point == ' ') || (*point == '\t')))
right(TRUE);
}
else
left(TRUE);
}