From 9cf480409cea5a67e89bd67d610974151c069a50 Mon Sep 17 00:00:00 2001 From: "Magomed Kostoev (mkostoevr)" Date: Tue, 19 May 2020 11:02:39 +0000 Subject: [PATCH] Add functions from Add memrchr.c git-svn-id: svn://kolibrios.org@7949 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/ktcc/trunk/bin/lib/libck.a | Bin 127772 -> 130124 bytes programs/develop/ktcc/trunk/libc/build.bat | 2 +- .../develop/ktcc/trunk/libc/include/libgen.h | 7 ++ .../develop/ktcc/trunk/libc/include/string.h | 1 + .../develop/ktcc/trunk/libc/libgen/basename.c | 23 ++++++ .../develop/ktcc/trunk/libc/libgen/dirname.c | 67 ++++++++++++++++++ .../develop/ktcc/trunk/libc/string/memrchr.c | 12 ++++ 7 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 programs/develop/ktcc/trunk/libc/include/libgen.h create mode 100644 programs/develop/ktcc/trunk/libc/libgen/basename.c create mode 100644 programs/develop/ktcc/trunk/libc/libgen/dirname.c create mode 100644 programs/develop/ktcc/trunk/libc/string/memrchr.c diff --git a/programs/develop/ktcc/trunk/bin/lib/libck.a b/programs/develop/ktcc/trunk/bin/lib/libck.a index 910d97397bc1e4a3b25ccf773d8ba7cb9ec3ded9..cd0266c33748c77b2a7fd99941a996c07f23cfdc 100644 GIT binary patch delta 4707 zcmb`L4Nz3q701un@Uax^Zjs4bKnNBb1u5Sk5Nq&bEmARPsm794K&jE<2jGmU8aEb6 zB;jY(I8D_EE1*%97(iLpgS>(-0DhAk-!$-bT<8Fl6eh%vF_b27I0jCsCOv=KxM^ z2ArM*m`kP4y91a{?HB6-=g{g4X9CXc1)P5nu$U$+y$@JMffn}xE?opzeim@WD8LGu zV-@+W_5oZ&n z8c-~*#ojh?pg-QhgLR3|aX{>kx4RxDXY+7o>kQZ1X_GkUa%W7{!*>Ux%{4!}$ybY} zfQX!*rRpG$GTv3yAaJ12In{>)$F{B3qjbwIxjO^BQDm@kceFp}(puN>m__|CKgZ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l7a`1B#QPsu-ntFdJg`o zKxL~bD(7N>2lUUwVxOH+f*8B881e4#GWSF=0-oH&dobMt%1f}&1O9YBNzaAeeFtx`J#oKVe119Z&rR~=c-Hn)~UIl3}UqF?XVTwJw@Pm;W0efaD4Do3z zZqbP;Qum;AU-Y%Xr*LIDO#55{udpHs2_mH(Jt`KplpNA5j7{<6VQs*0%jTopGD~PJ zB^Hd`_jBZIe3JY09;R6G3Kr^QWYF=idb=8e=f7J|G;N-vNW9a9STE-N6^S1o*YJf> zm{wg!k=Xq@YSj8AwIBKfHKOYT7Aahw%l9dx7k~GX*>B=+6C. */ + +#include + +char * +basename (const char *filename) +{ + char *p = strrchr (filename, '/'); + return p ? p + 1 : (char *) filename; +} diff --git a/programs/develop/ktcc/trunk/libc/libgen/dirname.c b/programs/develop/ktcc/trunk/libc/libgen/dirname.c new file mode 100644 index 0000000000..b889f7d0c6 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/libgen/dirname.c @@ -0,0 +1,67 @@ +/* dirname - return directory part of PATH. + Copyright (C) 1996-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +char * +dirname (char *path) +{ + static const char dot[] = "."; + char *last_slash; + /* Find last '/'. */ + last_slash = path != NULL ? strrchr (path, '/') : NULL; + if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') + { + /* Determine whether all remaining characters are slashes. */ + char *runp; + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + /* The '/' is the last character, we have to look further. */ + if (runp != path) + last_slash = memrchr (path, '/', runp - path); + } + if (last_slash != NULL) + { + /* Determine whether all remaining characters are slashes. */ + char *runp; + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + /* Terminate the path. */ + if (runp == path) + { + /* The last slash is the first character in the string. We have to + return "/". As a special case we have to return "//" if there + are exactly two slashes at the beginning of the string. See + XBD 4.10 Path Name Resolution for more information. */ + if (last_slash == path + 1) + ++last_slash; + else + last_slash = path + 1; + } + else + last_slash = runp; + last_slash[0] = '\0'; + } + else + /* This assignment is ill-designed but the XPG specs require to + return a string containing "." in any case no directory part is + found and so a static and constant string is required. */ + path = (char *) dot; + return path; +} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc/string/memrchr.c b/programs/develop/ktcc/trunk/libc/string/memrchr.c new file mode 100644 index 0000000000..742693a1e5 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/string/memrchr.c @@ -0,0 +1,12 @@ +/* memrchr.c from musl + */ + +#include + +void *memrchr(const void *m, int c, size_t n) +{ + const unsigned char *s = m; + c = (unsigned char)c; + while (n--) if (s[n]==c) return (void *)(s+n); + return 0; +}