Very old versions for history.
[opsoft_archive.git] / silentbob / silentbob-1.1 / src / sblib / ww_begin_line.cpp
blobe5655cbb311c14de49834d6ae7f108bb4e1a1b08
1 /*
2 * (c) Oleg Puchinin 2006.
3 * graycardinalster@gmail.com
5 */
7 #include "../head.h"
8 #include "../the_tt.h"
9 #include "../dbg.h"
11 int ww_begin_line (struct tt_state_t * d_tt_state, char *d_out, int d_offset)
13 char *S = &d_tt_state->d_file_in [d_offset] - 1;
14 char * d_end = &d_out[strlen (d_out)] - 1;
15 int Ret = 0;
17 while (d_end != d_out) {
18 if (*d_end == ' ' || *d_end == '\t') {
19 while (*S == ' ' || *S == '\t')
20 S--;
22 while ((*d_end == ' ' || *d_end == '\t')
23 && (d_end != d_out))
24 d_end--;
26 continue;
29 if (*S == '\n')
30 Ret--;
32 if (*S == *d_end)
33 d_end--;
35 S--;
36 d_offset--;
37 assert (d_offset < 0, "Lena 3");
40 return Ret;