[beast: 17/24] SFI: use Rapicorn's string_format()
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 17/24] SFI: use Rapicorn's string_format()
- Date: Thu, 24 Sep 2015 20:11:02 +0000 (UTC)
commit 0315312d2ff4ca5613e6dfcb14db55e7c8ae8d1e
Author: Tim Janik <timj gnu org>
Date: Wed Sep 23 11:02:24 2015 +0200
SFI: use Rapicorn's string_format()
sfi/sfidl-parser.cc | 2 +-
sfi/sfiserial.cc | 27 +--------------------------
sfi/sfistore.cc | 8 ++------
3 files changed, 4 insertions(+), 33 deletions(-)
---
diff --git a/sfi/sfidl-parser.cc b/sfi/sfidl-parser.cc
index 6ce87b6..14957dc 100644
--- a/sfi/sfidl-parser.cc
+++ b/sfi/sfidl-parser.cc
@@ -84,7 +84,7 @@ static GScannerConfig scanner_config_template = {
/* --- defines --- */
-#define DEBUG(x) // dprintf(2,"%s",x)
+#define DEBUG(x) // printerr ("%s", x)
enum ExtraToken {
TOKEN_NAMESPACE = G_TOKEN_LAST + 1,
diff --git a/sfi/sfiserial.cc b/sfi/sfiserial.cc
index ddef4bd..7499c7d 100644
--- a/sfi/sfiserial.cc
+++ b/sfi/sfiserial.cc
@@ -82,31 +82,6 @@ scanner_skip_statement (GScanner *scanner,
}
static String
-string_vprintf (const char *format, va_list vargs) // FIXME: move
-{
- char *str = NULL;
- if (vasprintf (&str, format, vargs) >= 0 && str)
- {
- String s = str;
- free (str);
- return s;
- }
- else
- return format;
-}
-
-static String
-string_printf (const char *format, ...) // FIXME: move
-{
- String str;
- va_list args;
- va_start (args, format);
- str = string_vprintf (format, args);
- va_end (args);
- return str;
-}
-
-static String
string_to_cescape (const String &str) // FIXME: move
{
String buffer;
@@ -114,7 +89,7 @@ string_to_cescape (const String &str) // FIXME: move
{
uint8 d = *it;
if (d < 32 || d > 126 || d == '?')
- buffer += string_printf ("\\%03o", d);
+ buffer += string_format ("\\%03o", d);
else if (d == '\\')
buffer += "\\\\";
else if (d == '"')
diff --git a/sfi/sfistore.cc b/sfi/sfistore.cc
index 4b4cc9a..c749d79 100644
--- a/sfi/sfistore.cc
+++ b/sfi/sfistore.cc
@@ -323,19 +323,15 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
{
BBlock *bblock = (BBlock*) ring->data;
off_t foff;
- gchar ptext[2 + 8 + 1 + 2 + 8 + 1];
- /* 0x *0* ' ' 0x *0* '\0' */
do
foff = lseek (fd, text_offset + bblock->patch_offset, SEEK_SET);
while (foff < 0 && errno == EINTR);
if (foff < 0 && errno)
return -errno;
- g_snprintf (ptext, sizeof (ptext), "0x%08x 0x%08x",
- (guint32) (bblock->offset - binary_offset),
- (guint32) bblock->length);
+ std::string str = string_format ("0x%08x 0x%08x", guint32 (bblock->offset - binary_offset), guint32
(bblock->length));
do
- l = write (fd, ptext, sizeof (ptext) - 1);
+ l = write (fd, str.data(), str.size());
while (l < 0 && errno == EINTR);
if (l < 0 && errno)
return -errno;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]