Skip to content

Commit

Permalink
[ICU-4358] Fixes for Windows.
Browse files Browse the repository at this point in the history
X-SVN-Rev: 17681
  • Loading branch information
grhoten committed May 25, 2005
1 parent ae97b1e commit e2533f2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 51 deletions.
21 changes: 7 additions & 14 deletions convexp/convexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,29 +719,22 @@ static void printAliasTable() {
* @returns 1 if open failed
*/
static int printTemplateFile(char *templateFileName) {
size_t size = 0;
size_t savedPos;
char *buffer;
FILE *templateFile = fopen(templateFileName, "r");

if (templateFile == NULL) {
printf("<!-- ERROR: %s cannot be opened -->\n", templateFileName);
return 1;
}

/* Go to the end, find the size, and go back to the beginning. */
savedPos = ftell(templateFile);
fseek(templateFile, 0, SEEK_END);
size = ftell(templateFile);
fseek(templateFile, savedPos, SEEK_SET);

/* Read in the whole file and print it out */
buffer = (char *)malloc(size+1);
memset(buffer, 0, size+1); // Make sure the whole buffer is NULL terminated
fread(buffer, size, 1, templateFile);
printf("%s", buffer);
while (!feof(templateFile)) {
int ch = fgetc(templateFile);
if (ch == -1) {
break;
}
printf("%c", ch);
}

free(buffer);
fclose(templateFile);
return 0;
}
Expand Down
31 changes: 12 additions & 19 deletions idnbrowser/idnbrwsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#include "idnbrwsr.h"
#include "demo_settings.h"

#ifdef WIN32
# define _WIN32_WINNT 0x0400
# include "windows.h"
#endif
//#ifdef WIN32
//# define _WIN32_WINNT 0x0400
//# include "windows.h"
//#endif

#include "parseqs.h"

#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))

static const char *htmlHeader=
static const char htmlHeader[]=
"Content-Type: text/html; charset=utf-8\n"
"\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
Expand Down Expand Up @@ -606,29 +606,22 @@ parseString(const char *s, int32_t srcLen,
* @returns 1 if open failed
*/
static int printTemplateFile(char *templateFileName) {
size_t size = 0;
size_t savedPos;
char *buffer;
FILE *templateFile = fopen(templateFileName, "r");

if (templateFile == NULL) {
printf("<!-- ERROR: %s cannot be opened -->\n", templateFileName);
return 1;
}

/* Go to the end, find the size, and go back to the beginning. */
savedPos = ftell(templateFile);
fseek(templateFile, 0, SEEK_END);
size = ftell(templateFile);
fseek(templateFile, savedPos, SEEK_SET);

/* Read in the whole file and print it out */
buffer = (char *)malloc(size+1);
memset(buffer, 0, size+1); // Make sure the whole buffer is NULL terminated
fread(buffer, size, 1, templateFile);
printf("%s", buffer);
while (!feof(templateFile)) {
int ch = fgetc(templateFile);
if (ch == -1) {
break;
}
printf("%c", ch);
}

free(buffer);
fclose(templateFile);
return 0;
}
Expand Down
29 changes: 11 additions & 18 deletions nbrowser/nbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,29 +289,22 @@ parseString(const char *s,
* @returns 1 if open failed
*/
static int printTemplateFile(char *templateFileName) {
size_t size = 0;
size_t savedPos;
char *buffer;
FILE *templateFile = fopen(templateFileName, "r");

if (templateFile == NULL) {
printf("<!-- ERROR: %s cannot be opened -->\n", templateFileName);
return 1;
}

/* Go to the end, find the size, and go back to the beginning. */
savedPos = ftell(templateFile);
fseek(templateFile, 0, SEEK_END);
size = ftell(templateFile);
fseek(templateFile, savedPos, SEEK_SET);

}

/* Read in the whole file and print it out */
buffer = (char *)malloc(size+1);
memset(buffer, 0, size+1); // Make sure the whole buffer is NULL terminated
fread(buffer, size, 1, templateFile);
printf("%s", buffer);

free(buffer);
while (!feof(templateFile)) {
int ch = fgetc(templateFile);
if (ch == -1) {
break;
}
printf("%c", ch);
}

fclose(templateFile);
return 0;
}
Expand Down

0 comments on commit e2533f2

Please sign in to comment.