Skip to content

Commit

Permalink
trurl: support compiling with old versions of Visual Studio
Browse files Browse the repository at this point in the history
- Define bool type and remove mixed declarations for old versions of
  Visual Studio.

This supports compiling trurl with old versions of Visual Studio by
using cl at the command line only. The winbuild solution still requires
recent versions of Visual Studio.

Closes #268
  • Loading branch information
jay committed Jan 24, 2024
1 parent 84f7a4a commit 1518a4b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <curl/curl.h>
#include <curl/mprintf.h>
#include <stdint.h>

#if defined(_MSC_VER) && (_MSC_VER < 1800)
typedef enum {
bool_false = 0,
bool_true = 1
} bool;
#define false bool_false
#define true bool_true
#else
#include <stdbool.h>
#endif

#include <locale.h> /* for setlocale() */

#include "version.h"
Expand Down Expand Up @@ -980,11 +990,12 @@ static void trim(struct option *o)
{
struct curl_slist *node;
for(node = o->trim_list; node; node = node->next) {
char *ptr;
char *instr = node->data;
if(strncmp(instr, "query", 5))
/* for now we can only trim query components */
errorf(o, ERROR_TRIM, "Unsupported trim component: %s", instr);
char *ptr = strchr(instr, '=');
ptr = strchr(instr, '=');
if(ptr && (ptr > instr)) {
/* 'ptr' should be a fixed string or a pattern ending with an
asterisk */
Expand Down Expand Up @@ -1068,6 +1079,7 @@ static struct string *memdupdec(char *source, size_t len, bool json)
int right_len = 0;
int left_len = 0;
char *str;
struct string *ret;

left = strurldecode(source, (int)(sep ? (size_t)(sep - source) : len),
&left_len);
Expand All @@ -1094,7 +1106,7 @@ static struct string *memdupdec(char *source, size_t len, bool json)
}
curl_free(right);
curl_free(left);
struct string *ret = malloc(sizeof(struct string));
ret = malloc(sizeof(struct string));
if(!ret) {
return NULL;
}
Expand Down Expand Up @@ -1200,10 +1212,11 @@ static void qpair2query(CURLU *uh, struct option *o)
/* sort case insensitively */
static int cmpfunc(const void *p1, const void *p2)
{
int i;
int len = (int)((((struct string *)p1)->len) < (((struct string *)p2)->len)?
(((struct string *)p1)->len) : (((struct string *)p2)->len));

for(int i = 0; i < len; i++) {
for(i = 0; i < len; i++) {
char c1 = ((struct string *)p1)->str[i] | ('a' - 'A');
char c2 = ((struct string *)p2)->str[i] | ('a' - 'A');
if(c1 != c2)
Expand Down

0 comments on commit 1518a4b

Please sign in to comment.