forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Johannes Schindelin <[email protected]>
- Loading branch information
Showing
41 changed files
with
368 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "test-tool.h" | ||
#include "git-compat-util.h" | ||
#include "strbuf.h" | ||
#include "gettext.h" | ||
#include "parse-options.h" | ||
#include "utf8.h" | ||
|
||
int cmd__iconv(int argc, const char **argv) | ||
{ | ||
struct strbuf buf = STRBUF_INIT; | ||
char *from = NULL, *to = NULL, *p; | ||
size_t len; | ||
int ret = 0; | ||
const char * const iconv_usage[] = { | ||
N_("test-helper --iconv [<options>]"), | ||
NULL | ||
}; | ||
struct option options[] = { | ||
OPT_STRING('f', "from-code", &from, "encoding", "from"), | ||
OPT_STRING('t', "to-code", &to, "encoding", "to"), | ||
OPT_END() | ||
}; | ||
|
||
argc = parse_options(argc, argv, NULL, options, | ||
iconv_usage, 0); | ||
|
||
if (argc > 1 || !from || !to) | ||
usage_with_options(iconv_usage, options); | ||
|
||
if (!argc) { | ||
if (strbuf_read(&buf, 0, 2048) < 0) | ||
die_errno("Could not read from stdin"); | ||
} else if (strbuf_read_file(&buf, argv[0], 2048) < 0) | ||
die_errno("Could not read from '%s'", argv[0]); | ||
|
||
p = reencode_string_len(buf.buf, buf.len, to, from, &len); | ||
if (!p) | ||
die_errno("Could not reencode"); | ||
if (write(1, p, len) < 0) | ||
ret = !!error_errno("Could not write %"PRIuMAX" bytes", | ||
(uintmax_t)len); | ||
|
||
strbuf_release(&buf); | ||
free(p); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.