Skip to content

Commit be8c69c

Browse files
author
Alex Cole
committed
Debugging
1 parent 1b5aefb commit be8c69c

File tree

3 files changed

+85
-43
lines changed

3 files changed

+85
-43
lines changed

YSI_Core/y_testing/y_testing_entry.inc

+49-43
Original file line numberDiff line numberDiff line change
@@ -401,49 +401,55 @@ stock
401401
//#define _Q@y0000%0\32; _Q@y0000
402402
//#define _y@Q0000%0\32; _y@Q0000
403403

404-
/*-------------------------------------------------------------------------*//**
405-
* <library>y_testing</library>
406-
* <param name="a">The first string to compare.</param>
407-
* <param name="b">The second string to compare.</param>
408-
* <remarks>
409-
* A wrapper for <c>strcmp</c> that takes a pointer instead of a string.
410-
* </remarks>
411-
*//*------------------------------------------------------------------------**/
412-
413-
native Testing_StrCmp__(const a[], b, bool:ignoreCase = false, length = cellmax) = strcmp;
414-
415-
/*-------------------------------------------------------------------------*//**
416-
* <library>y_testing</library>
417-
* <param name="name">Name of the current test.</param>
418-
* <remarks>
419-
* If <c>JUST_TEST</c> is defined this confirms whether the current test is
420-
* in the list of desired tests.
421-
* </remarks>
422-
*//*------------------------------------------------------------------------**/
423-
424-
static stock bool:Testing_ShouldRun(const name[], ...)
425-
{
426-
new
427-
n = numargs() - 1,
428-
addr,
429-
str;
430-
#emit ADDR.pri __param1_offset
431-
#emit STOR.S.pri addr
432-
while (n--)
433-
{
434-
#emit LREF.S.pri addr
435-
#emit STOR.S.pri str
436-
addr += cellbytes;
437-
if (Testing_StrCmp__(name, str) == 0)
438-
{
439-
return true;
440-
}
441-
}
442-
return false;
443-
}
444-
445-
// Detect multiple parameters and convert them all to strings.
446-
#define Testing_ShouldRun(%0""#%1,%2) Testing_ShouldRun(%0#%1,""#%2)
404+
///*-------------------------------------------------------------------------*//**
405+
// * <library>y_testing</library>
406+
// * <param name="a">The first string to compare.</param>
407+
// * <param name="b">The second string to compare.</param>
408+
// * <remarks>
409+
// * A wrapper for <c>strcmp</c> that takes a pointer instead of a string.
410+
// * </remarks>
411+
// *//*------------------------------------------------------------------------**/
412+
//
413+
//native Testing_StrCmp__(const a[], b, bool:ignoreCase = false, length = cellmax) = strcmp;
414+
//
415+
///*-------------------------------------------------------------------------*//**
416+
// * <library>y_testing</library>
417+
// * <param name="name">Name of the current test.</param>
418+
// * <remarks>
419+
// * If <c>JUST_TEST</c> is defined this confirms whether the current test is
420+
// * in the list of desired tests.
421+
// * </remarks>
422+
// *//*------------------------------------------------------------------------**/
423+
//
424+
//static stock bool:Testing_ShouldRun(const name[], ...)
425+
//{
426+
// new
427+
// n = numargs() - 1,
428+
// addr,
429+
// str;
430+
// #emit ADDR.pri __param1_offset
431+
// #emit STOR.S.pri addr
432+
// while (n--)
433+
// {
434+
// #emit LREF.S.pri addr
435+
// #emit STOR.S.pri str
436+
// addr += cellbytes;
437+
// if (Testing_StrCmp__(name, str) == 0)
438+
// {
439+
// return true;
440+
// }
441+
// }
442+
// return false;
443+
//}
444+
//
445+
//// Detect multiple parameters and convert them all to strings.
446+
//#define Testing_ShouldRun(%0""#%1,%2) Testing_ShouldRun(%0#%1,""#%2)
447+
448+
// Until I work out the macro for `Testing_ShouldRun` to stringise multiple
449+
// arguments, despite them being given in `JUST_TEST`, which is evaluated later
450+
// in the pre-processing step, just alias this to `strcmp` and stick with the
451+
// old method.
452+
#define Testing_ShouldRun(%0,%1) (!strcmp(%0,%1))
447453

448454
/*-------------------------------------------------------------------------*//**
449455
* <library>y_testing</library>

YSI_Storage/y_ini/y_ini_impl.inc

+18
Original file line numberDiff line numberDiff line change
@@ -1690,46 +1690,55 @@ INI_ReadFile_cont:
16901690

16911691
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_yyyy, y_ini:y_ini_reading_nyyy>
16921692
{
1693+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_yyy> called: %s, %s", key, value);
16931694
@.YSI_g_sCB_issss(YSI_g_sExtra, YSI_g_sFile, YSI_g_sTag, key, value);
16941695
}
16951696

16961697
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_yyyn, y_ini:y_ini_reading_nyyn>
16971698
{
1699+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_yyn> called: %s, %s", key, value);
16981700
@.YSI_g_sCB_isss(YSI_g_sExtra, YSI_g_sTag, key, value);
16991701
}
17001702

17011703
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_yyny, y_ini:y_ini_reading_nyny>
17021704
{
1705+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_yny> called: %s, %s", key, value);
17031706
@.YSI_g_sCB_isss(YSI_g_sExtra, YSI_g_sFile, key, value);
17041707
}
17051708

17061709
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_yynn, y_ini:y_ini_reading_nynn>
17071710
{
1711+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_ynn> called: %s, %s", key, value);
17081712
@.YSI_g_sCB_iss(YSI_g_sExtra, key, value);
17091713
}
17101714

17111715
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_ynyy, y_ini:y_ini_reading_nnyy>
17121716
{
1717+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_nyy> called: %s, %s", key, value);
17131718
@.YSI_g_sCB_ssss(YSI_g_sFile, YSI_g_sTag, key, value);
17141719
}
17151720

17161721
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_ynyn, y_ini:y_ini_reading_nnyn>
17171722
{
1723+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_nyn> called: %s, %s", key, value);
17181724
@.YSI_g_sCB_sss(YSI_g_sTag, key, value);
17191725
}
17201726

17211727
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_ynny, y_ini:y_ini_reading_nnny>
17221728
{
1729+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_nny> called: %s, %s", key, value);
17231730
@.YSI_g_sCB_sss(YSI_g_sFile, key, value);
17241731
}
17251732

17261733
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_reading_ynnn, y_ini:y_ini_reading_nnnn>
17271734
{
1735+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_reading_nnn> called: %s, %s", key, value);
17281736
@.YSI_g_sCB_ss(key, value);
17291737
}
17301738

17311739
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_writing_slow>
17321740
{
1741+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_writing_slow> called: %s, %s", key, value);
17331742
// Used when reading. Checks if the key is being overwritten, and if not
17341743
// writes it out to the new file.
17351744
INI_WriteTag(YSI_g_sCurrentFile, YSI_g_sTag, YSI_g_sFormat);
@@ -1746,15 +1755,21 @@ static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_writing_sl
17461755
// Not deleted.
17471756
if (INI_KeyListGetValue(mem))
17481757
{
1758+
Debug_Print6("INI_HandleEntry<y_ini:y_ini_writing_slow> updated");
17491759
INI_KeyListRemove(prev, mem),
17501760
INI_KeyListMakeWritable(mem),
17511761
fwrite(YSI_g_sCurrentFile, INI_KeyListGetKey(mem)),
17521762
// Remove this from the list.
17531763
free(mem);
17541764
}
1765+
else
1766+
{
1767+
Debug_Print6("INI_HandleEntry<y_ini:y_ini_writing_slow> deleted");
1768+
}
17551769
}
17561770
else
17571771
{
1772+
Debug_Print6("INI_HandleEntry<y_ini:y_ini_writing_slow> unchanged");
17581773
// Write the entry.
17591774
fwrite(YSI_g_sCurrentFile, key),
17601775
fwrite(YSI_g_sCurrentFile, "="),
@@ -1765,6 +1780,7 @@ static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_writing_sl
17651780

17661781
static stock INI_HandleEntry(const key[], const value[]) <y_ini:y_ini_writing_fast>
17671782
{
1783+
Debug_Print5("INI_HandleEntry<y_ini:y_ini_writing_fast> called: %s, %s", key, value);
17681784
// Nothing in the current tag is being overwritten, just dump this
17691785
// key/value pair straight to disk with no extra checks.
17701786
INI_WriteTag(YSI_g_sCurrentFile, YSI_g_sTag, YSI_g_sFormat);
@@ -2079,12 +2095,14 @@ static stock INI_Flush_(INI:file)
20792095
// You can't delete the no-tag tag.
20802096
if (INI_TagListGetEntries(YSI_g_sCurrentTag))
20812097
{
2098+
Debug_Print5("INI_Flush_: Writing slow");
20822099
// Slightly slower, as for every key we need to check if there is a
20832100
// new value being written.
20842101
state y_ini:y_ini_writing_slow;
20852102
}
20862103
else
20872104
{
2105+
Debug_Print5("INI_Flush_: Writing fast");
20882106
// Nothing to write, just copy all the existing data.
20892107
YSI_g_sCurrentTag = NO_ALLOC;
20902108
}

YSI_Storage/y_ini/y_ini_tests.inc

+18
Original file line numberDiff line numberDiff line change
@@ -951,25 +951,43 @@ public INI_PUB_Inl_(string:name[], string:value[])
951951
fclose(f);
952952
}
953953

954+
printf("a:");
955+
if ((f = fopen(MakeYINITestPath("test10.ini"), io_read)))
956+
{
957+
while (fread(f, str)) printf(str);
958+
fclose(f);
959+
}
960+
954961
new INI:i = INI_Open(MakeYINITestPath("test10.ini"));
955962
INI_SetTag(i, "tag_with_parent");
956963
INI_RemoveEntry(i, "value");
957964
INI_Close(i);
958965

966+
printf("b:");
967+
if ((f = fopen(MakeYINITestPath("test10.ini"), io_read)))
968+
{
969+
while (fread(f, str)) printf(str);
970+
fclose(f);
971+
}
972+
959973
f = fopen(MakeYINITestPath("test10.ini"), io_read);
960974
ASSERT(!!f);
961975
if (f)
962976
{
963977
fread(f, str);
978+
printf("Read file: %s", str);
964979
StripNL(str);
965980
ASSERT_SAME(str, "[tag_with_parent]");
966981
fread(f, str);
982+
printf("Read file: %s", str);
967983
StripNL(str);
968984
ASSERT_SAME(str, "value_four=Some_semi_colons");
969985
fread(f, str);
986+
printf("Read file: %s", str);
970987
StripNL(str);
971988
ASSERT_SAME(str, "value_three=Some\\;semi\\;colons");
972989
fread(f, str);
990+
printf("Read file: %s", str);
973991
StripNL(str);
974992
ASSERT_SAME(str, "");
975993
fclose(f);

0 commit comments

Comments
 (0)