summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-11-06 11:36:34 -0800
committerGitHub <noreply@github.com>2017-11-06 11:36:34 -0800
commit1082eabb680cf6083f59071918d007d5314c59ea (patch)
tree8d5ba22a893c9fcf1d7e84fb5a8fc6b0e0242649
parent8233f6e36d8827986e1baeff4b7b4daa2cce46f4 (diff)
parentbf15dbf6cf19146082c1245e9db4016d773dbe7e (diff)
downloadlibgit2-1082eabb680cf6083f59071918d007d5314c59ea.tar.gz
Merge pull request #4397 from pks-t/pks/appveyor-examples
appveyor: build examples
-rw-r--r--appveyor.yml2
-rw-r--r--examples/network/common.c41
-rwxr-xr-xscript/appveyor-mingw.sh2
3 files changed, 41 insertions, 4 deletions
diff --git a/appveyor.yml b/appveyor.yml
index 1ba8abbd1..e0c7b9b90 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -36,7 +36,7 @@ build_script:
mkdir build
cd build
if ($env:GENERATOR -ne "MSYS Makefiles") {
- cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D MSVC_CRTDBG=ON .. -G"$env:GENERATOR"
+ cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D BUILD_EXAMPLES=ON -D MSVC_CRTDBG=ON .. -G"$env:GENERATOR"
cmake --build . --config Debug
}
- cmd: |
diff --git a/examples/network/common.c b/examples/network/common.c
index 1a81a10f8..b0afb0238 100644
--- a/examples/network/common.c
+++ b/examples/network/common.c
@@ -16,6 +16,43 @@
# define UNUSED(x) x
#endif
+static int readline(char **out)
+{
+ int c, error = 0, length = 0, allocated = 0;
+ char *line = NULL;
+
+ errno = 0;
+
+ while ((c = getchar()) != EOF) {
+ if (length == allocated) {
+ allocated += 16;
+
+ if ((line = realloc(line, allocated)) == NULL) {
+ error = -1;
+ goto error;
+ }
+ }
+
+ if (c == '\n')
+ break;
+
+ line[length++] = c;
+ }
+
+ if (errno != 0) {
+ error = -1;
+ goto error;
+ }
+
+ line[length] = '\0';
+ *out = line;
+ line = NULL;
+ error = length;
+error:
+ free(line);
+ return error;
+}
+
int cred_acquire_cb(git_cred **out,
const char * UNUSED(url),
const char * UNUSED(username_from_url),
@@ -26,14 +63,14 @@ int cred_acquire_cb(git_cred **out,
int error;
printf("Username: ");
- if (getline(&username, NULL, stdin) < 0) {
+ if (readline(&username) < 0) {
fprintf(stderr, "Unable to read username: %s", strerror(errno));
return -1;
}
/* Yup. Right there on your terminal. Careful where you copy/paste output. */
printf("Password: ");
- if (getline(&password, NULL, stdin) < 0) {
+ if (readline(&password) < 0) {
fprintf(stderr, "Unable to read password: %s", strerror(errno));
free(username);
return -1;
diff --git a/script/appveyor-mingw.sh b/script/appveyor-mingw.sh
index d171a72d5..6b2a9425e 100755
--- a/script/appveyor-mingw.sh
+++ b/script/appveyor-mingw.sh
@@ -19,5 +19,5 @@ fi
cd build
gcc --version
cmake --version
-cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR"
+cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D BUILD_EXAMPLES=ON .. -G"$GENERATOR"
cmake --build . --config RelWithDebInfo