]> git.ozlabs.org Git - ccan/commitdiff
global: replace grab_file() with grab_file_str().
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Oct 2025 03:23:30 +0000 (13:53 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Oct 2025 03:23:30 +0000 (13:53 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
27 files changed:
ccan/aga/test/api-lazytrie.c
ccan/ccan_tokenizer/_info
ccan/cdump/_info
ccan/cdump/tools/cdump-enumstr.c
ccan/charset/_info
ccan/crc32c/benchmark/bench.c
ccan/crcsync/_info
ccan/htable/tools/hsearchspeed.c
ccan/htable/tools/stringspeed.c
ccan/rfc822/examples/headernames.c
ccan/rune/test/run.c
ccan/strset/_info
ccan/strset/tools/cbspeed.c
ccan/strset/tools/speed.c
ccan/tal/grab_file/_info
ccan/tal/str/_info
ccan/ungraph/_info
tools/ccanlint/tests/info_compiles.c
tools/ccanlint/tests/info_documentation_exists.c
tools/ccanlint/tests/tests_coverage.c
tools/ccanlint/tests/tests_pass_valgrind.c
tools/depends.c
tools/doc_extract.c
tools/manifest.c
tools/namespacize.c
tools/read_config_header.c
tools/tools.c

index feea4d16838d399c4ac5dd11453df28b3d6a6abe..421298cff34bf65768748c4b143fe84ce866e624 100644 (file)
@@ -52,7 +52,7 @@ static void setup_words(void)
        char *wordfile;
 
        /* read in the words */
-       wordfile = grab_file(NULL, "test/api-lazytrie-words.txt");
+       wordfile = grab_file_str(NULL, "test/api-lazytrie-words.txt");
        ok1(wordfile);
        wordarray = tal_strsplit(NULL, take(wordfile), "\n", STR_NO_EMPTY);
        ok1(wordarray);
index f5116b4fc80103957d6e74feb7ee1ac8b7def9c3..dd8c4e0025bb22ba3ba1e0f52daf8491bfa9f95e 100644 (file)
@@ -58,7 +58,7 @@
  *             fprintf(stderr, "Usage: %s source_file\n", argv[0]);
  *             return 1;
  *     }
- *     file = grab_file(NULL, argv[1]);
+ *     file = grab_file_str(NULL, argv[1]);
  *     if (!file)
  *             err(1, "Could not read file %s", argv[1]);
  *
index c79d013b2c8a08ebb7bb826bd8c40ad2f64e4591..5c2acee75d39bd39ea44bbfd067bb2d02ff344b6 100644 (file)
@@ -33,7 +33,7 @@
  *     size_t j;
  *
  *     // Read code from stdin.
- *     code = grab_file(NULL, NULL);
+ *     code = grab_file_str(NULL, NULL);
  *
  *     defs = cdump_extract(NULL, code, &problems);
  *     if (!defs)
index f0b70ecdb57460be181fcca49358f81c9b5104f8..147f2a231fd90fde5b611a5f79a0b89ea5d5785a 100644 (file)
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
        if (argc < 2)
                errx(1, "Usage: cdump-enumstr <filename> [<enums>...]");
 
-       code = grab_file(NULL, streq(argv[1], "-") ? NULL : argv[1]);
+       code = grab_file_str(NULL, streq(argv[1], "-") ? NULL : argv[1]);
        if (!code)
                err(1, "Reading %s", argv[1]);
 
index 919acda618641b57dd73e4901bb3b7c9e1dab91b..a966176d97db580abaef031bf26e635950b002cd 100644 (file)
@@ -25,7 +25,7 @@
  *     {
  *             char *input;
  *     
- *             input = grab_file(NULL, NULL);
+ *             input = grab_file_str(NULL, NULL);
  *             if (!input)
  *                     err(1, "Error reading input");
  *             if (!utf8_validate(input, tal_count(input)-1)) {
index 54b2d97aa249144e7ff83791e51771168812974d..e584ae71ba4333931603ee288a408d412a65273a 100644 (file)
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
        if (argc < 2 || (runs = atol(argv[1])) == 0)
                errx(1, "Usage: bench <num-runs> [<file>]");
 
-       p = grab_file(NULL, argv[2]);
+       p = grab_file_str(NULL, argv[2]);
        if (!p)
                err(1, "Reading %s", argv[2] ? argv[2] : "<stdin>");
        len = tal_count(p) - 1;
index 7516f447480603c7722b61020953b9716980af50..92617da8357084eb567059d3d76cd7ce9b09b7bb 100644 (file)
@@ -38,7 +38,7 @@
  *                     errx(1, "Usage: %s <blocksize> <file> <crc>...\n"
  *                          "OR: %s <blocksize> <file>", argv[0], argv[0]);
  *     
- *             file = grab_file(NULL, argv[2]);
+ *             file = grab_file_str(NULL, argv[2]);
  *             if (!file)
  *                     err(1, "Opening file %s", argv[2]);
  *             len = tal_count(file) - 1;
index 88280114f3842f432170782b49b801146c035495..bed6f859dc1d48218c4fdb27fa9115252acbd3d3 100644 (file)
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
        char **w;
        ENTRY *words, *misswords;
 
-       w = tal_strsplit(NULL, grab_file(NULL,
+       w = tal_strsplit(NULL, grab_file_str(NULL,
                                         argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY);
        num = tal_count(w) - 1;
        printf("%zu words\n", num);
index 5f30359a585eeaee1b6a94d3bf5c7ec7d7eeb311..24eb15877f0d8595f4c23a7171bc775ab54bef00 100644 (file)
@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
        struct htable_str ht;
        char **words, **misswords;
 
-       words = tal_strsplit(NULL, grab_file(NULL,
+       words = tal_strsplit(NULL, grab_file_str(NULL,
                                             argv[1] ? argv[1] : "/usr/share/dict/words"), "\n",
                             STR_NO_EMPTY);
        htable_str_init(&ht);
index 161ceab322be489892fd2f18a460019e8be0b264..7ef871edde2aebde36de74949859f0f0579a86c9 100644 (file)
@@ -18,7 +18,7 @@ static void process_file(const char *name)
        struct rfc822_msg *msg;
        struct rfc822_header *hdr;
 
-       buf = grab_file(ctx, name, &size);
+       buf = grab_file_str(ctx, name, &size);
 
        msg = rfc822_start(ctx, buf, size);
 
index d90b701c609cc48401029f8988e97dfe660f7f21..85cb6903b84deeb44ac3fd3b0f733c2520cce921 100644 (file)
@@ -39,7 +39,7 @@ int main(void)
        mr = rune_new(NULL, secret_zero, sizeof(secret_zero), NULL); 
 
        /* Python runes library generates test vectors */
-       vecs = grab_file(mr, "test/test_vectors.csv");
+       vecs = grab_file_str(mr, "test/test_vectors.csv");
        assert(vecs);
        lines = tal_strsplit(mr, take(vecs), "\n", STR_NO_EMPTY);
 
index 982a9c0f851ae7d5485b42cc2e53578125613e14..bcd261b92e90dd0bb6f2bc7a68e6232df6052b13 100644 (file)
@@ -32,7 +32,7 @@
  *             char *file, *word;
  *
  *             strset_init(&words);
- *             file = grab_fd(NULL, 0);
+ *             file = grab_fd_str(NULL, 0);
  *             if (!file)
  *                     err(1, "Reading stdin");
  *
index 5d551b6e2c7fb54e1b58faff805aac0b2317e8b5..88ce981a28581bfe3c40621730ba36087e6862a6 100644 (file)
@@ -395,7 +395,7 @@ int main(int argc, char *argv[])
        critbit0_tree ct;
        char **words, **misswords;
 
-       words = tal_strsplit(NULL, grab_file(NULL,
+       words = tal_strsplit(NULL, grab_file_str(NULL,
                                         argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY);
        ct.root = NULL;
        num = tal_count(words) - 1;
index 325b3a888d63e9787c99dd3103b76cb5936ec372..70a43c2569f9f24283519fb9289e8133ff49f554 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
        struct strset set;
        char **words, **misswords;
 
-       words = tal_strsplit(NULL, grab_file(NULL,
+       words = tal_strsplit(NULL, grab_file_str(NULL,
                                             argv[1] ? argv[1] : "/usr/share/dict/words"),
                             "\n", STR_NO_EMPTY);
        strset_init(&set);
index 0c18e6dc8778045f9ab2ad557370cf462a7732e8..9b130a5fba9f9381ccebb5e1f28dea276ae28ccf 100644 (file)
@@ -20,7 +20,7 @@
  *
  *             if (argc > 2)
  *                     err(1, "Takes 0 or 1 arguments");
- *             file = grab_file(NULL, argv[1]);
+ *             file = grab_file_str(NULL, argv[1]);
  *             if (!file)
  *                     err(1, "Could not read file %s", argv[1]);
  *             if (strlen(file)+1 != tal_count(file))
index 9b9c70b6be7f1198e684e23dc0bf892f41fbb04f..83e089e717e91808a5c87868888a42a1a2b15023 100644 (file)
@@ -25,7 +25,7 @@
  *             if (argc > 2)
  *                     errx(1, "Takes 0 or 1 arguments");
  *             // Grab lines in file.
- *             textfile = grab_file(NULL, argv[1]);
+ *             textfile = grab_file_str(NULL, argv[1]);
  *             if (!textfile)
  *                     err(1, "Failed reading %s", argv[1]);
  *             lines = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
index 6088c5e4f61504a5f16b5dadd7424d169ab44018..d38d3113155b73be0b2e7ab2ca05b6359969b726 100644 (file)
@@ -50,7 +50,7 @@
  *
  * int main(int argc, char *argv[])
  * {
- *         const char *graph = grab_file(NULL, argv[1], NULL), *errmsg;
+ *         const char *graph = grab_file_str(NULL, argv[1], NULL), *errmsg;
  *        printf("digraph %s {\n", argv[1] ? argv[1] : "stdin");
  *         errmsg = ungraph(NULL, graph, add_node, add_edge, NULL);
  *         if (errmsg)
index e1485963e8fbb479be8aac8da0c9c098fb923695..f839c856da2119c99db179109976e82639608e65 100644 (file)
@@ -31,7 +31,7 @@ static void check_info_compiles(struct manifest *m,
        }
 
        /* Copy it to a file with proper .c suffix. */
-       info = grab_file(score, m->info_file->fullname);
+       info = grab_file_str(score, m->info_file->fullname);
        if (!info) {
                score_file_error(score, m->info_file, 0,
                                 "could not be read: %s", strerror(errno));
index c3f02226b869b5182c8fe49a76a9133c98bc9ddf..9b1cb549482f744f15d2c3cef7d307dfd8f60744 100644 (file)
@@ -52,7 +52,7 @@ static void create_info_template_doc(struct manifest *m,
                err(1, "Writing to _info.new to insert documentation");
        }
 
-       oldcontents = grab_file(m, m->info_file->fullname);
+       oldcontents = grab_file_str(m, m->info_file->fullname);
        if (!oldcontents) {
                unlink_noerr("_info.new");
                err(1, "Reading %s", m->info_file->fullname);
index e29572019141e81fd8b77a4abc4e1d7931170860..401b4bf4160b7dbf0b73b94178315926aea79dc2 100644 (file)
@@ -100,7 +100,7 @@ static void analyze_coverage(struct manifest *m, bool full_gcov,
                        apostrophe = strchr(filename, '\'');
                        *apostrophe = '\0';
                        if (lines_matter) {
-                               file = grab_file(score, filename);
+                               file = grab_file_str(score, filename);
                                if (!file) {
                                        score->error = tal_fmt(score,
                                                               "Reading %s",
index 90e42349715f9ff2c0ef706e54123072f5f52212..2fbcc0876bdcb4072ee31b225633f51fd26168b8 100644 (file)
@@ -181,7 +181,7 @@ static void do_run_tests_vg(struct manifest *m,
                                continue;
                        }
 
-                       output = grab_file(i, i->valgrind_log);
+                       output = grab_file_str(i, i->valgrind_log);
                        /* No valgrind errors? */
                        if (!output || output[0] == '\0') {
                                err = NULL;
index e8e0f138dc0900e2349ccf14580bd25fdd2b8b95..63f5012429051c0dec9370c4c022c0420e76aa5a 100644 (file)
@@ -49,7 +49,7 @@ char *compile_info(const void *ctx, const char *dir)
        int fd;
 
        /* Copy it to a file with proper .c suffix. */
-       info = grab_file(ctx, tal_fmt(ctx, "%s/_info", dir));
+       info = grab_file_str(ctx, tal_fmt(ctx, "%s/_info", dir));
        if (!info)
                return NULL;
 
@@ -131,7 +131,7 @@ static char **get_one_safe_deps(const void *ctx,
        bool correct_style = false;
 
        fname = path_join(ctx, dir, "_info");
-       raw = grab_file(fname, fname);
+       raw = grab_file_str(fname, fname);
        if (!raw)
                errx(1, "Could not open %s", fname);
 
index 99c3202ca0bf2ccd1034b113a02cc71a6a27fe32..95bf9fe3f3478f2a968a757adbb766c8324b74bd 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
                struct list_head *list;
                struct doc_section *d;
 
-               file = grab_file(NULL, argv[i]);
+               file = grab_file_str(NULL, argv[i]);
                if (!file)
                        err(1, "Reading file %s", argv[i]);
                lines = tal_strsplit(file, file, "\n", STR_EMPTY_OK);
index fcc2f15ba39231940e08b81dfed1ffa71df75314..5a9791e45f2195f095398c5afc06c2d3a9abe8da 100644 (file)
@@ -44,10 +44,10 @@ static struct htable_manifest *manifests;
 const char *get_ccan_file_contents(struct ccan_file *f)
 {
        if (!f->contents) {
-               f->contents = grab_file(f, f->fullname);
+               f->contents = grab_file_str(f, f->fullname);
                if (!f->contents)
                        err(1, "Reading file %s", f->fullname);
-               f->contents_size = tal_count(f->contents) - 1;
+               f->contents_size = tal_count(f->contents);
        }
        return f->contents;
 }
index ae20e3d66c136e83b4675526f9d76c34647d8b41..c3c56757ca9b1ec5e37d2f8289fb5e7c6007fe97 100644 (file)
@@ -252,7 +252,7 @@ static void analyze_headers(const char *dir, struct replace **repl)
        hdr = tal_fmt(dir, "%s.h",
                      path_join(NULL, dir, take(path_basename(NULL, dir))));
 
-       contents = grab_file(dir, hdr);
+       contents = grab_file_str(dir, hdr);
        if (!contents)
                err(1, "Reading %s", hdr);
 
@@ -327,7 +327,7 @@ static const char *rewrite_file(const char *filename,
        int fd;
 
        verbose("Rewriting %s\n", filename);
-       file = grab_file(filename, filename);
+       file = grab_file_str(filename, filename);
        if (!file)
                err(1, "Reading file %s", filename);
 
@@ -424,7 +424,7 @@ static struct replace *read_replacement_file(const char *depdir)
        char *replname = path_join(depdir, depdir, ".namespacize");
        char *file, **line;
 
-       file = grab_file(replname, replname);
+       file = grab_file_str(replname, replname);
        if (!file) {
                if (errno != ENOENT)
                        err(1, "Opening %s", replname);
index da3e00cd73ba7088981d7a40ad3b995c4ad48e2b..ff2af3b329173970137167334289ac523442321c 100644 (file)
@@ -95,7 +95,7 @@ char *read_config_header(const char *ccan_dir, bool verbose)
        unsigned int i;
        char *config_header;
 
-       config_header = grab_file(NULL, fname);
+       config_header = grab_file_str(NULL, fname);
 
        if (!config_header) {
                tal_free(fname);
index 6a96c943ab2c66ada77688606cce316df6ec1df1..bb1f80d5eccc2284f627b20560e9ad07b60382f4 100644 (file)
@@ -233,7 +233,7 @@ bool move_file(const char *oldname, const char *newname)
        }
 
        /* Try copy and delete: not atomic! */
-       contents = grab_file(NULL, oldname);
+       contents = grab_file_str(NULL, oldname);
        if (!contents) {
                if (tools_verbose)
                        printf("read failed: %s\n", strerror(errno));