[njs] Removed njs_file.c not needed after 8aad26845b18 (0.8.3).

Dmitry Volyntsev xeioex at nginx.com
Thu Feb 8 01:57:53 UTC 2024


details:   https://hg.nginx.org/njs/rev/45f72ce8761b
branches:  
changeset: 2284:45f72ce8761b
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Feb 07 17:57:01 2024 -0800
description:
Removed njs_file.c not needed after 8aad26845b18 (0.8.3).

diffstat:

 auto/sources             |   1 -
 src/njs_file.c           |  69 ---------------------------------
 src/njs_file.h           |  15 -------
 src/njs_main.h           |   1 -
 src/test/njs_unit_test.c |  98 ------------------------------------------------
 5 files changed, 0 insertions(+), 184 deletions(-)

diffs (236 lines):

diff -r 93562e512d26 -r 45f72ce8761b auto/sources
--- a/auto/sources	Wed Feb 07 17:56:59 2024 -0800
+++ b/auto/sources	Wed Feb 07 17:57:01 2024 -0800
@@ -17,7 +17,6 @@ NJS_LIB_SRCS=" \
    src/njs_sha1.c \
    src/njs_sha2.c \
    src/njs_time.c \
-   src/njs_file.c \
    src/njs_malloc.c \
    src/njs_mp.c \
    src/njs_sprintf.c \
diff -r 93562e512d26 -r 45f72ce8761b src/njs_file.c
--- a/src/njs_file.c	Wed Feb 07 17:56:59 2024 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-
-#include <njs_main.h>
-
-
-void
-njs_file_basename(const njs_str_t *path, njs_str_t *name)
-{
-    const u_char  *p, *end;
-
-    end = path->start + path->length;
-    p = end - 1;
-
-    /* Stripping dir prefix. */
-
-    while (p >= path->start && *p != '/') { p--; }
-
-    p++;
-
-    name->start = (u_char *) p;
-    name->length = end - p;
-}
-
-
-void
-njs_file_dirname(const njs_str_t *path, njs_str_t *name)
-{
-    const u_char  *p, *end;
-
-    if (path->length == 0) {
-        goto current_dir;
-    }
-
-    p = path->start + path->length - 1;
-
-    /* Stripping basename. */
-
-    while (p >= path->start && *p != '/') { p--; }
-
-    end = p + 1;
-
-    if (end == path->start) {
-        goto current_dir;
-    }
-
-    /* Stripping trailing slashes. */
-
-    while (p >= path->start && *p == '/') { p--; }
-
-    p++;
-
-    if (p == path->start) {
-        p = end;
-    }
-
-    name->start = path->start;
-    name->length = p - path->start;
-
-    return;
-
-current_dir:
-
-    *name = njs_str_value(".");
-}
diff -r 93562e512d26 -r 45f72ce8761b src/njs_file.h
--- a/src/njs_file.h	Wed Feb 07 17:56:59 2024 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-#ifndef _NJS_FILE_H_INCLUDED_
-#define _NJS_FILE_H_INCLUDED_
-
-
-void njs_file_basename(const njs_str_t *path, njs_str_t *name);
-void njs_file_dirname(const njs_str_t *path, njs_str_t *name);
-
-
-#endif /* _NJS_FILE_H_INCLUDED_ */
diff -r 93562e512d26 -r 45f72ce8761b src/njs_main.h
--- a/src/njs_main.h	Wed Feb 07 17:56:59 2024 -0800
+++ b/src/njs_main.h	Wed Feb 07 17:57:01 2024 -0800
@@ -28,7 +28,6 @@
 #include <njs_flathsh.h>
 #include <njs_random.h>
 #include <njs_time.h>
-#include <njs_file.h>
 #include <njs_malloc.h>
 #include <njs_rbtree.h>
 #include <njs_mp.h>
diff -r 93562e512d26 -r 45f72ce8761b src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Wed Feb 07 17:56:59 2024 -0800
+++ b/src/test/njs_unit_test.c	Wed Feb 07 17:57:01 2024 -0800
@@ -6,7 +6,6 @@
 
 #include <njs.h>
 #include <njs_unix.h>
-#include <njs_file.h>
 #include <njs_utils.h>
 #include <njs_queue.h>
 #include <njs_string.h>
@@ -24449,99 +24448,6 @@ njs_vm_object_alloc_test(njs_vm_t *vm, n
 
 
 static njs_int_t
-njs_file_basename_test(njs_vm_t *vm, njs_opts_t *opts, njs_stat_t *stat)
-{
-    njs_str_t   name;
-    njs_bool_t  success;
-    njs_uint_t  i;
-
-    static const struct {
-        njs_str_t   path;
-        njs_str_t   expected;
-    } tests[] = {
-        { njs_str(""),            njs_str("") },
-        { njs_str("/"),           njs_str("") },
-        { njs_str("/a"),          njs_str("a") },
-        { njs_str("///"),         njs_str("") },
-        { njs_str("///a"),        njs_str("a") },
-        { njs_str("///a/"),       njs_str("") },
-        { njs_str("a"),           njs_str("a") },
-        { njs_str("a/"),          njs_str("") },
-        { njs_str("a//"),         njs_str("") },
-        { njs_str("path/name"),   njs_str("name") },
-        { njs_str("/path/name"),  njs_str("name") },
-        { njs_str("/path/name/"), njs_str("") },
-    };
-
-    for (i = 0; i < njs_nitems(tests); i++) {
-        njs_file_basename(&tests[i].path, &name);
-
-        success = njs_strstr_eq(&tests[i].expected, &name);
-
-        if (!success) {
-            njs_printf("njs_file_basename_test(\"%V\"):\n"
-                       "expected: \"%V\"\n     got: \"%V\"\n",
-                       &tests[i].path, &tests[i].expected, &name);
-
-            stat->failed++;
-
-        } else {
-            stat->passed++;
-        }
-    }
-
-    return NJS_OK;
-}
-
-
-static njs_int_t
-njs_file_dirname_test(njs_vm_t *vm, njs_opts_t *opts, njs_stat_t *stat)
-{
-    njs_str_t   name;
-    njs_bool_t  success;
-    njs_uint_t  i;
-
-    static const struct {
-        njs_str_t   path;
-        njs_str_t   expected;
-    } tests[] = {
-        { njs_str(""),               njs_str(".") },
-        { njs_str("/"),              njs_str("/") },
-        { njs_str("/a"),             njs_str("/") },
-        { njs_str("///"),            njs_str("///") },
-        { njs_str("///a"),           njs_str("///") },
-        { njs_str("///a/"),          njs_str("///a") },
-        { njs_str("a"),              njs_str(".") },
-        { njs_str("a/"),             njs_str("a") },
-        { njs_str("a//"),            njs_str("a") },
-        { njs_str("p1/p2/name"),     njs_str("p1/p2") },
-        { njs_str("/p1/p2/name"),    njs_str("/p1/p2") },
-        { njs_str("/p1/p2///name"),  njs_str("/p1/p2") },
-        { njs_str("/p1/p2/name/"),   njs_str("/p1/p2/name") },
-    };
-
-    for (i = 0; i < njs_nitems(tests); i++) {
-        njs_file_dirname(&tests[i].path, &name);
-
-        success = njs_strstr_eq(&tests[i].expected, &name);
-
-        if (!success) {
-            njs_printf("njs_file_dirname_test(\"%V\"):\n"
-                       "expected: \"%V\"\n     got: \"%V\"\n",
-                       &tests[i].path, &tests[i].expected, &name);
-
-            stat->failed++;
-        } else {
-            stat->passed++;
-        }
-
-    }
-
-    return NJS_OK;
-}
-
-
-static njs_int_t
 njs_chb_test(njs_vm_t *vm, njs_opts_t *opts, njs_stat_t *stat)
 {
     u_char     *p;
@@ -24935,10 +24841,6 @@ njs_vm_internal_api_test(njs_unit_test_t
     } tests[] = {
         { njs_vm_object_alloc_test,
           njs_str("njs_vm_object_alloc_test") },
-        { njs_file_basename_test,
-          njs_str("njs_file_basename_test") },
-        { njs_file_dirname_test,
-          njs_str("njs_file_dirname_test") },
         { njs_chb_test,
           njs_str("njs_chb_test") },
         { njs_sort_test,


More information about the nginx-devel mailing list