MCPcopy Create free account
hub / github.com/git/git / emit_rewrite_lines

Function emit_rewrite_lines

diff.c:1834–1872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1832}
1833
1834static void emit_rewrite_lines(struct emit_callback *ecbdata,
1835 int prefix, const char *data, int size)
1836{
1837 const char *endp = NULL;
1838
1839 while (0 < size) {
1840 int len, plen;
1841 char *pdata = NULL;
1842
1843 endp = memchr(data, '\n', size);
1844
1845 if (endp) {
1846 len = endp - data + 1;
1847 plen = len;
1848 } else {
1849 len = size;
1850 plen = len + 1;
1851 pdata = xmalloc(plen + 2);
1852 memcpy(pdata, data, len);
1853 pdata[len] = '\n';
1854 pdata[len + 1] = '\0';
1855 }
1856 if (prefix != '+') {
1857 ecbdata->lno_in_preimage++;
1858 emit_del_line(ecbdata, pdata ? pdata : data, plen);
1859 } else {
1860 ecbdata->lno_in_postimage++;
1861 emit_add_line(ecbdata, pdata ? pdata : data, plen);
1862 }
1863 free(pdata);
1864 size -= len;
1865 data += len;
1866 }
1867 if (!endp) {
1868 static const char nneof[] = "\\ No newline at end of file\n";
1869 ecbdata->last_line_kind = prefix;
1870 emit_incomplete_line_marker(ecbdata, nneof, sizeof(nneof) - 1);
1871 }
1872}
1873
1874static void emit_rewrite_diff(const char *name_a,
1875 const char *name_b,

Callers 1

emit_rewrite_diffFunction · 0.85

Calls 4

emit_del_lineFunction · 0.85
emit_add_lineFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected