mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 15:54:56 +00:00
Fixed a buglet where an extra newline was being added after an insert command
in some cases.
This commit is contained in:
parent
497ef46587
commit
56c14a6473
@ -333,17 +333,20 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ptr[idx] = '\n';
|
|
||||||
ptr[idx+1] = 0;
|
|
||||||
|
|
||||||
/* this accounts for discrepancies between the modified string and the
|
/* this accounts for discrepancies between the modified string and the
|
||||||
* original string passed in to this function */
|
* original string passed in to this function */
|
||||||
idx += slashes_eaten;
|
idx += slashes_eaten;
|
||||||
|
|
||||||
/* this accounts for the fact that A) we started at index 3, not at index
|
/* figure out if we need to add a newline */
|
||||||
* 0 and B) that we added an extra '\n' at the end (if you think the next
|
if (ptr[idx-1] != '\n') {
|
||||||
* line should read 'idx += 4' remember, arrays are zero-based) */
|
ptr[idx] = '\n';
|
||||||
idx += 3;
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* terminate string */
|
||||||
|
ptr[idx]= 0;
|
||||||
|
/* adjust for opening 2 chars [aic]\ */
|
||||||
|
idx += 2;
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
17
sed.c
17
sed.c
@ -333,17 +333,20 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ptr[idx] = '\n';
|
|
||||||
ptr[idx+1] = 0;
|
|
||||||
|
|
||||||
/* this accounts for discrepancies between the modified string and the
|
/* this accounts for discrepancies between the modified string and the
|
||||||
* original string passed in to this function */
|
* original string passed in to this function */
|
||||||
idx += slashes_eaten;
|
idx += slashes_eaten;
|
||||||
|
|
||||||
/* this accounts for the fact that A) we started at index 3, not at index
|
/* figure out if we need to add a newline */
|
||||||
* 0 and B) that we added an extra '\n' at the end (if you think the next
|
if (ptr[idx-1] != '\n') {
|
||||||
* line should read 'idx += 4' remember, arrays are zero-based) */
|
ptr[idx] = '\n';
|
||||||
idx += 3;
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* terminate string */
|
||||||
|
ptr[idx]= 0;
|
||||||
|
/* adjust for opening 2 chars [aic]\ */
|
||||||
|
idx += 2;
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user