strbuf: add xstrdup_toupper()
Create a copy of an existing string and make all characters upper case. Similar xstrdup_tolower(). This function is used in a subsequent commit. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lars Schneider committed
Feb 15, 2018 at 16:27 UTC
13ecb4638ed92a56e855d2e6d3a9b71c4125eb51
2 files changed
+13
strbuf.c
+12
@@ -784,6 +784,18 @@ char *xstrdup_tolower(const char *string)
784
return result;
785
}
786
787
+char *xstrdup_toupper(const char *string)
788
+{
789
+ char *result;
790
+ size_t len, i;
791
+
792
+ len = strlen(string);
793
+ result = xmallocz(len);
794
+ for (i = 0; i < len; i++)
795
+ result[i] = toupper(string[i]);
796
+ return result;
797
+}
798
+
799
char *xstrvfmt(const char *fmt, va_list ap)
800
{
801
struct strbuf buf = STRBUF_INIT;
strbuf.h
+1
@@ -607,6 +607,7 @@ __attribute__((format (printf,2,3)))
607
extern int fprintf_ln(FILE *fp, const char *fmt, ...);
608
609
char *xstrdup_tolower(const char *);
610
+char *xstrdup_toupper(const char *);
611
612
/**
613
* Create a newly allocated string using printf format. You can do this easily