Skip to content

Commit 1082eab

Browse files
authored
Merge pull request libgit2#4397 from pks-t/pks/appveyor-examples
appveyor: build examples
2 parents 8233f6e + bf15dbf commit 1082eab

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ build_script:
3636
mkdir build
3737
cd build
3838
if ($env:GENERATOR -ne "MSYS Makefiles") {
39-
cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D MSVC_CRTDBG=ON .. -G"$env:GENERATOR"
39+
cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D BUILD_EXAMPLES=ON -D MSVC_CRTDBG=ON .. -G"$env:GENERATOR"
4040
cmake --build . --config Debug
4141
}
4242
- cmd: |

examples/network/common.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@
1616
# define UNUSED(x) x
1717
#endif
1818

19+
static int readline(char **out)
20+
{
21+
int c, error = 0, length = 0, allocated = 0;
22+
char *line = NULL;
23+
24+
errno = 0;
25+
26+
while ((c = getchar()) != EOF) {
27+
if (length == allocated) {
28+
allocated += 16;
29+
30+
if ((line = realloc(line, allocated)) == NULL) {
31+
error = -1;
32+
goto error;
33+
}
34+
}
35+
36+
if (c == '\n')
37+
break;
38+
39+
line[length++] = c;
40+
}
41+
42+
if (errno != 0) {
43+
error = -1;
44+
goto error;
45+
}
46+
47+
line[length] = '\0';
48+
*out = line;
49+
line = NULL;
50+
error = length;
51+
error:
52+
free(line);
53+
return error;
54+
}
55+
1956
int cred_acquire_cb(git_cred **out,
2057
const char * UNUSED(url),
2158
const char * UNUSED(username_from_url),
@@ -26,14 +63,14 @@ int cred_acquire_cb(git_cred **out,
2663
int error;
2764

2865
printf("Username: ");
29-
if (getline(&username, NULL, stdin) < 0) {
66+
if (readline(&username) < 0) {
3067
fprintf(stderr, "Unable to read username: %s", strerror(errno));
3168
return -1;
3269
}
3370

3471
/* Yup. Right there on your terminal. Careful where you copy/paste output. */
3572
printf("Password: ");
36-
if (getline(&password, NULL, stdin) < 0) {
73+
if (readline(&password) < 0) {
3774
fprintf(stderr, "Unable to read password: %s", strerror(errno));
3875
free(username);
3976
return -1;

script/appveyor-mingw.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ fi
1919
cd build
2020
gcc --version
2121
cmake --version
22-
cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR"
22+
cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D BUILD_EXAMPLES=ON .. -G"$GENERATOR"
2323
cmake --build . --config RelWithDebInfo

0 commit comments

Comments
 (0)