Lines Matching refs:line
87 /* Sed operates a line at a time. */
88 struct line {
89 char *text; /* Pointer to line allocated by malloc. */
100 #define SIZEOF_LINE offsetof (struct line, mbstate)
102 #define SIZEOF_LINE (sizeof (struct line))
126 /* Current input line number (over all files). */
129 /* True if we'll reset line numbers and addresses before
133 /* Function to read one line. If FP is NULL, read_fn better not
136 bool (*read_fn) P_((struct input *)); /* read one line */
158 /* The `current' input line. */
159 static struct line line;
161 /* An input line used to accumulate the result of the s and e commands. */
162 static struct line s_accum;
164 /* An input line that's been stored by later use by the program */
165 static struct line hold;
169 static struct line buffer;
204 /* increase a struct line's length, making some attempt at
206 static void resize_line P_((struct line *, size_t));
209 struct line *lb;
238 /* Append `length' bytes from `string' to the line `to'. */
239 static void str_append P_((struct line *, const char *, size_t));
242 struct line *to;
277 static void str_append_modified P_((struct line *, const char *, size_t,
281 struct line *to;
387 /* Initialize a "struct line" buffer. Copy multibyte state from `state'
389 static void line_init P_((struct line *, struct line *, size_t initial_size));
392 struct line *buf;
393 struct line *state;
410 /* Reset a "struct line" buffer to length zero. Copy multibyte state from
412 static void line_reset P_((struct line *, struct line *));
415 struct line *buf, *state;
431 /* Copy the contents of the line `from' into the line `to'.
434 static void line_copy P_((struct line *from, struct line *to, int state));
437 struct line *from;
438 struct line *to;
468 /* Append the contents of the line `from' to the line `to'.
470 static void line_append P_((struct line *from, struct line *to, int state));
473 struct line *from;
474 struct line *to;
487 /* Exchange two "struct line" buffers.
489 static void line_exchange P_((struct line *a, struct line *b, int state));
492 struct line *a;
493 struct line *b;
496 struct line t;
500 MEMCPY(&t, a, sizeof (struct line));
501 MEMCPY( a, b, sizeof (struct line));
502 MEMCPY( b, &t, sizeof (struct line));
535 /* Remove the trailing new-line that is left by getline. */
539 line.chomped = false;
541 str_append(&line, b, result);
857 /* Read in the next line of input, and store it in the pattern space.
870 line.length = 0;
871 line.chomped = true; /* default, until proved otherwise */
888 new-line to this file; but if the output goes to stdout,
889 we might still have to output the missing new-line. */
949 /* Return non-zero if the current line matches the address
963 return match_regex(addr->addr_regex, line.active, line.length, 0, NULL, 0);
1029 /* Same handling as below, but always include at least one line. */
1050 /* If the second address is a line number, and if we got past
1051 that line, fail to match (it can happen when you jump
1074 unsigned char *p = CAST(unsigned char *)line.active;
1075 countT len = line.length;
1130 static enum replacement_types append_replacement P_((struct line *, struct replacement *,
1135 struct line *buf;
1169 str_append_modified(buf, line.active + regs->start[i],
1183 size_t start = 0; /* where to start scan for (next) match in LINE */
1184 size_t last_end = 0; /* where did the last successful match end in LINE */
1190 line_reset(&s_accum, &line);
1194 if (!match_regex(sub->regx, line.active, line.length, start,
1205 line.active += regs.end[0];
1206 line.length -= regs.end[0];
1207 line.alloc -= regs.end[0];
1210 else if (regs.end[0] == line.length)
1215 line.length = regs.start[0];
1229 str_append(&s_accum, line.active + start, offset - start);
1257 if (start < line.length)
1263 str_append(&s_accum, line.active + offset, matched);
1273 && start <= line.length
1274 && match_regex(sub->regx, line.active, line.length, start,
1278 if (start < line.length)
1279 str_append(&s_accum, line.active + start, line.length-start);
1280 s_accum.chomped = line.chomped;
1282 /* Exchange line and s_accum. This can be much cheaper
1283 than copying s_accum.active into line.text (for huge lines). */
1284 line, &s_accum, false);
1292 output_line(line.active, line.length, line.chomped, &output_file);
1300 str_append (&line, "", 1);
1301 pipe_fp = popen(line.active, "r");
1315 /* Exchange line and s_accum. This can be much cheaper than copying
1316 s_accum.active into line.text (for huge lines). See comment above
1318 line_exchange(&line, &s_accum, true);
1319 if (line.length &&
1320 line.active[line.length - 1] == '\n')
1321 line.length--;
1331 output_line(line.active, line.length, line.chomped, &output_file);
1333 output_line(line.active, line.length, line.chomped, sub->outf);
1389 /* Execute the program `vec' on the current input line.
1440 char *p = memchr(line.active, '\n', line.length);
1445 line.alloc -= p - line.active;
1446 line.length -= p - line.active;
1447 line.active += p - line.active;
1449 /* reset to start next cycle without reading a new line: */
1462 str_append (&line, "", 1);
1463 pipe_fp = popen(line.active, "r");
1493 /* Exchange line and s_accum. This can be much
1494 cheaper than copying s_accum.active into line.text
1497 line_exchange(&line, &s_accum, true);
1519 line_copy(&hold, &line, true);
1528 line_append(&hold, &line, true);
1533 line_copy(&line, &hold, true);
1538 line_append(&line, &hold, true);
1555 fmt(line.active, line.active + line.length,
1565 output_line(line.active, line.length, line.chomped, &output_file);
1571 str_append(&line, "\n", 1);
1575 line.length--;
1577 output_line(line.active, line.length, line.chomped,
1584 output_line(line.active, line.length, line.chomped, &output_file);
1589 char *p = memchr(line.active, '\n', line.length);
1590 output_line(line.active, p ? p - line.active : line.length,
1591 p ? true : line.chomped, &output_file);
1597 output_line(line.active, line.length, line.chomped, &output_file);
1655 output_line(line.active, line.length,
1656 line.chomped, cur_cmd->x.outf);
1662 char *p = memchr(line.active, '\n', line.length);
1663 output_line(line.active, p ? p - line.active : line.length,
1664 p ? true : line.chomped, cur_cmd->x.outf);
1670 line_exchange(&line, &hold, false);
1678 int idx, prev_idx; /* index in the input line. */
1682 for (idx = 0; idx < line.length;)
1685 mbclen = MBRLEN (line.active + idx, line.length - idx,
1698 if (strncmp(line.active + idx, trans[2*i], mbclen) == 0)
1706 new_len = line.length + 1 + trans_len - mbclen;
1707 /* We must extend the line buffer. */
1708 if (line.alloc < new_len)
1711 resize_line(&line, new_len);
1717 /* We must truncate the line buffer. */
1726 move_from = line.active + idx + mbclen;
1727 move_to = line.active + idx + trans_len;
1728 move_len = line.length + 1 - idx - mbclen;
1731 line.length += move_offset;
1734 strncpy(line.active + prev_idx, trans[2*i+1],
1746 p = CAST(unsigned char *)line.active;
1747 for (e=p+line.length; p<e; ++p)
1754 line.length = 0;
1772 line we should be able to quit if no_default_output is true,
1778 version will terminate after printing line two in the script
1781 Don't use this when in-place editing is active, because line
1822 output_line(line.active, line.length, line.chomped, &output_file);
1840 line_init(&line, NULL, INITIAL_BUFFER_SIZE);
1880 FREE(line.text);