Unverified Commit 1082eabb by Edward Thomson Committed by GitHub

Merge pull request #4397 from pks-t/pks/appveyor-examples

appveyor: build examples
parents 8233f6e3 bf15dbf6
...@@ -36,7 +36,7 @@ build_script: ...@@ -36,7 +36,7 @@ build_script:
mkdir build mkdir build
cd build cd build
if ($env:GENERATOR -ne "MSYS Makefiles") { 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 cmake --build . --config Debug
} }
- cmd: | - cmd: |
......
...@@ -16,6 +16,43 @@ ...@@ -16,6 +16,43 @@
# define UNUSED(x) x # define UNUSED(x) x
#endif #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, int cred_acquire_cb(git_cred **out,
const char * UNUSED(url), const char * UNUSED(url),
const char * UNUSED(username_from_url), const char * UNUSED(username_from_url),
...@@ -26,14 +63,14 @@ int cred_acquire_cb(git_cred **out, ...@@ -26,14 +63,14 @@ int cred_acquire_cb(git_cred **out,
int error; int error;
printf("Username: "); printf("Username: ");
if (getline(&username, NULL, stdin) < 0) { if (readline(&username) < 0) {
fprintf(stderr, "Unable to read username: %s", strerror(errno)); fprintf(stderr, "Unable to read username: %s", strerror(errno));
return -1; return -1;
} }
/* Yup. Right there on your terminal. Careful where you copy/paste output. */ /* Yup. Right there on your terminal. Careful where you copy/paste output. */
printf("Password: "); printf("Password: ");
if (getline(&password, NULL, stdin) < 0) { if (readline(&password) < 0) {
fprintf(stderr, "Unable to read password: %s", strerror(errno)); fprintf(stderr, "Unable to read password: %s", strerror(errno));
free(username); free(username);
return -1; return -1;
......
...@@ -19,5 +19,5 @@ fi ...@@ -19,5 +19,5 @@ fi
cd build cd build
gcc --version gcc --version
cmake --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 cmake --build . --config RelWithDebInfo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment