From 3c2873bbdcae1bdee090f3eec659d51521ac4bf9 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 22 Jan 2014 01:28:25 +0000 Subject: [PATCH] [syslinux] fix missing syslinux.cfg creation * Issue was introduced with 299506056ac441f23d25839525741832d26865e9 * Also improve StrArray definition --- src/iso.c | 18 +++++++++--------- src/rufus.c | 16 ++++++++-------- src/rufus.h | 3 +-- src/rufus.rc | 10 +++++----- src/stdfn.c | 24 ++++++++++++------------ 5 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/iso.c b/src/iso.c index 47a02b98..4e6966ae 100644 --- a/src/iso.c +++ b/src/iso.c @@ -580,17 +580,17 @@ out: // If multiple config files exist, choose the one with the shortest path // (so that a '/syslinux.cfg' is preferred over a '/isolinux/isolinux.cfg') if (!IsStrArrayEmpty(config_path)) { - safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[0]); + safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[0]); for (i=1; i safe_strlen(config_path.Table[i])) - safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[i]); + if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.String[i])) + safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[i]); } uprintf("Will use %s for Syslinux\n", iso_report.cfg_path); // Extract all of the isolinux.bin files we found to identify their versions for (i=0; i= 5)) ) uprintf("Warning: Conflict between Isolinux version and the presence of ldlinux.c32...\n"); @@ -656,7 +656,7 @@ out: } StrArrayDestroy(&config_path); StrArrayDestroy(&isolinux_path); - } else if (!IsStrArrayEmpty(config_path)) { + } else if (HAS_SYSLINUX(iso_report)) { safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir); // Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg fd = fopen(path, "r"); diff --git a/src/rufus.c b/src/rufus.c index 7a8fdd18..fd6d4b3e 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -589,7 +589,7 @@ static BOOL PopulateProperties(int ComboIndex) SetTargetSystem(); SetFSFromISO(); EnableBootOptions(TRUE); - device_tooltip = (char*) malloc(safe_strlen(DriveID.Table[ComboIndex]) + 16); + device_tooltip = (char*) malloc(safe_strlen(DriveID.String[ComboIndex]) + 16); // Set a proposed label according to the size (eg: "256MB", "8GB") if (HumanReadableSize < 1.0) { @@ -601,14 +601,14 @@ static BOOL PopulateProperties(int ComboIndex) safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label), "%0.0f%s", ceil(HumanReadableSize), lmprintf(MSG_020+i)); if (device_tooltip != NULL) - safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16, - "%s (%0.0f%s)", DriveID.Table[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i)); + safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16, + "%s (%0.0f%s)", DriveID.String[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i)); } else { safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label), "%0.2f%s", HumanReadableSize, lmprintf(MSG_020+i)); if (device_tooltip != NULL) - safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16, - "%s (%0.2f%s)", DriveID.Table[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i)); + safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16, + "%s (%0.2f%s)", DriveID.String[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i)); } // Add a tooltip (with the size of the device in parenthesis) @@ -618,11 +618,11 @@ static BOOL PopulateProperties(int ComboIndex) // If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB") if ((iso_path == NULL) || (iso_report.label[0] == 0)) { - if ( (safe_stricmp(no_label, DriveLabel.Table[ComboIndex]) == 0) - || (safe_stricmp(lmprintf(MSG_207), DriveLabel.Table[ComboIndex]) == 0) ) { + if ( (safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0) + || (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0) ) { SetWindowTextU(hLabel, SelectedDrive.proposed_label); } else { - SetWindowTextU(hLabel, DriveLabel.Table[ComboIndex]); + SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]); } } else { SetWindowTextU(hLabel, iso_report.label); diff --git a/src/rufus.h b/src/rufus.h index c9b25059..d04d87cb 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -369,8 +369,7 @@ static __inline void *_reallocf(void *ptr, size_t size) /* Basic String Array */ typedef struct { - // TODO: rename 'Table' to 'String' - char** Table; + char** String; size_t Index; // Current array size size_t Max; // Maximum array size } StrArray; diff --git a/src/rufus.rc b/src/rufus.rc index da94302b..754d16c5 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.4.3.387" +CAPTION "Rufus v1.4.3.388" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -288,8 +288,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,3,387 - PRODUCTVERSION 1,4,3,387 + FILEVERSION 1,4,3,388 + PRODUCTVERSION 1,4,3,388 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -306,13 +306,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.3.387" + VALUE "FileVersion", "1.4.3.388" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.3.387" + VALUE "ProductVersion", "1.4.3.388" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index 10998662..07bcb1e5 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Standard Windows function calls - * Copyright © 2013 Pete Batard + * Copyright © 2013-2014 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -151,28 +151,28 @@ void StrArrayCreate(StrArray* arr, size_t initial_size) { if (arr == NULL) return; arr->Max = initial_size; arr->Index = 0; - arr->Table = (char**)calloc(arr->Max, sizeof(char*)); - if (arr->Table == NULL) + arr->String = (char**)calloc(arr->Max, sizeof(char*)); + if (arr->String == NULL) uprintf("Could not allocate string array\n"); } void StrArrayAdd(StrArray* arr, const char* str) { char** old_table; - if ((arr == NULL) || (arr->Table == NULL)) + if ((arr == NULL) || (arr->String == NULL)) return; if (arr->Index == arr->Max) { arr->Max *= 2; - old_table = arr->Table; - arr->Table = (char**)realloc(arr->Table, arr->Max*sizeof(char*)); - if (arr->Table == NULL) { + old_table = arr->String; + arr->String = (char**)realloc(arr->String, arr->Max*sizeof(char*)); + if (arr->String == NULL) { free(old_table); uprintf("Could not reallocate string array\n"); return; } } - arr->Table[arr->Index] = safe_strdup(str); - if (arr->Table[arr->Index++] == NULL) { + arr->String[arr->Index] = safe_strdup(str); + if (arr->String[arr->Index++] == NULL) { uprintf("Could not store string in array\n"); } } @@ -180,10 +180,10 @@ void StrArrayAdd(StrArray* arr, const char* str) void StrArrayClear(StrArray* arr) { size_t i; - if ((arr == NULL) || (arr->Table == NULL)) + if ((arr == NULL) || (arr->String == NULL)) return; for (i=0; iIndex; i++) { - safe_free(arr->Table[i]); + safe_free(arr->String[i]); } arr->Index = 0; } @@ -192,7 +192,7 @@ void StrArrayDestroy(StrArray* arr) { StrArrayClear(arr); if (arr != NULL) - safe_free(arr->Table); + safe_free(arr->String); } /*