[PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-07 Thread René Scharfe
Move strbuf_addchars() to strbuf.c, where it belongs, and make it
available for other callers.

Signed-off-by: Rene Scharfe 
---
 Documentation/technical/api-strbuf.txt | 4 
 strbuf.c   | 7 +++
 strbuf.h   | 1 +
 utf8.c | 7 ---
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Documentation/technical/api-strbuf.txt 
b/Documentation/technical/api-strbuf.txt
index 430302c..cca6543 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -160,6 +160,10 @@ then they will free() it.
 
Add a single character to the buffer.
 
+`strbuf_addchars`::
+
+   Add a character the specified number of times to the buffer.
+
 `strbuf_insert`::
 
Insert data to the given position of the buffer. The remaining contents
diff --git a/strbuf.c b/strbuf.c
index 4d31443..0346e74 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -204,6 +204,13 @@ void strbuf_adddup(struct strbuf *sb, size_t pos, size_t 
len)
strbuf_setlen(sb, sb->len + len);
 }
 
+void strbuf_addchars(struct strbuf *sb, int c, size_t n)
+{
+   strbuf_grow(sb, n);
+   memset(sb->buf + sb->len, c, n);
+   strbuf_setlen(sb, sb->len + n);
+}
+
 void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
 {
va_list ap;
diff --git a/strbuf.h b/strbuf.h
index 7bdc1da..652b6c4 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -138,6 +138,7 @@ static inline void strbuf_addbuf(struct strbuf *sb, const 
struct strbuf *sb2)
strbuf_add(sb, sb2->buf, sb2->len);
 }
 extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
+extern void strbuf_addchars(struct strbuf *sb, int c, size_t n);
 
 typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, 
void *context);
 extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t 
fn, void *context);
diff --git a/utf8.c b/utf8.c
index b30790d..6d4d04a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -239,13 +239,6 @@ int is_utf8(const char *text)
return 1;
 }
 
-static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
-{
-   strbuf_grow(sb, n);
-   memset(sb->buf + sb->len, c, n);
-   strbuf_setlen(sb, sb->len + n);
-}
-
 static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
 int indent, int indent2)
 {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-08 Thread Junio C Hamano
René Scharfe  writes:

> Move strbuf_addchars() to strbuf.c, where it belongs, and make it
> available for other callers.
>
> Signed-off-by: Rene Scharfe 

Wow, fixing up v1.7.0.2~9^2~2?

Both patches look correct, but I have to wonder where you are
drawing these clean-up opportunities from?  Almost as if reading
through dormant part of the codebase one of your hobbies or
something ;-)

Jokes aside, I very much appreciate it.  Thanks.



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-08 Thread René Scharfe

Am 08.09.2014 um 20:32 schrieb Junio C Hamano:

René Scharfe  writes:


Move strbuf_addchars() to strbuf.c, where it belongs, and make it
available for other callers.

Signed-off-by: Rene Scharfe 


Wow, fixing up v1.7.0.2~9^2~2?


About time, isn't it? ;)


Both patches look correct, but I have to wonder where you are
drawing these clean-up opportunities from?  Almost as if reading
through dormant part of the codebase one of your hobbies or
something ;-)


That, and I'm sitting on a pile of cleanup patches that grew whenever I 
looked at some piece of code for the first time, e.g. due to bug 
reports, or when I took a static analyzer for a test drive etc.  I'm 
trying to filter out the good ones and to send them at opportune moments 
in order to avoid conflicts with real changes.


René
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html