Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_diff.h File Reference

Line oriented text comparison (Myers shortest edit script). More...

#include "nilorea/n_list.h"
#include "nilorea/n_str.h"
Include dependency graph for n_diff.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_DIFF_LINE
 one line of an edit script More...
struct  N_DIFF_RESULT
 edit script turning one text into another More...

Macros

#define N_DIFF_COMMON   0
 the line is present in both texts
#define N_DIFF_CONTEXT_FULL   ((size_t)-1)
 n_diff_to_unified() context asking for every common line, without hunk headers
#define N_DIFF_DELETE   1
 the line is only in the first text
#define N_DIFF_INSERT   2
 the line is only in the second text
#define N_DIFF_MAX_EDITS_CEILING   4000
 hard ceiling n_diff_lines() clamps max_edits to, keeping the worst case trace under about 64 MB
#define N_DIFF_MAX_EDITS_DEFAULT   1000
 n_diff_lines() default ceiling on the number of differing lines searched
#define N_DIFF_NO_LINE   ((size_t)-1)
 N_DIFF_LINE line_a / line_b value when the line has no counterpart there.

Functions

N_DIFF_RESULT * n_diff_lines (const char *text_a, const char *text_b, size_t max_edits)
 Compare two texts line by line.
void n_diff_result_free (N_DIFF_RESULT **result)
 Free an edit script and every line it holds.
N_STR * n_diff_to_unified (const N_DIFF_RESULT *result, size_t context)
 Render an edit script as unified diff text.

Detailed Description

Line oriented text comparison (Myers shortest edit script).

Author
Castagnier Mickael
Version
1.0
Date
31/07/2026

Definition in file n_diff.h.