From 4e75bda5fc7583ec8f04fb6f7b678289515d99ed Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 23 Jan 2008 23:51:53 +0000 Subject: [PATCH] changed: variables and functions are case-sensitive now added: variables and functions can have underline characters in their names git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@62 e52654a7-88a9-db11-a3e9-0013d4bc506e --- help/arithmetic_functions.html | 9 +++++++++ help/operators_priority.html | 1 + help/userfunctions.html | 6 +++--- src/functions.cpp | 4 ++-- src/iniparser.cpp | 31 +++++++++++++++++++++++++++++-- src/iniparser.h | 30 ++++++++++++++++++++++++++++++ src/languages.cpp | 8 ++++---- src/mainwindow.cpp | 3 ++- src/programresources.cpp | 5 +++++ src/variables.cpp | 4 ++-- 10 files changed, 87 insertions(+), 14 deletions(-) diff --git a/help/arithmetic_functions.html b/help/arithmetic_functions.html index 8b3558f..0f8e0c7 100644 --- a/help/arithmetic_functions.html +++ b/help/arithmetic_functions.html @@ -49,6 +49,8 @@ + + @@ -193,6 +195,13 @@ the function returns the max value which can be held in this precision.
This functions takes any number of arguments. It returns the min value of them. If there aren't arguments the function returns the min value which can be held in this precision.
+
sum(x1; x2; ...)
+
This functions takes one or more arguments. It returns the sum of them.
+ +
avg(x1; x2; ...)
+
This functions takes one or more arguments. It returns the arithmetic mean. (The sum divided by +the number of arguments)
+ diff --git a/help/operators_priority.html b/help/operators_priority.html index d8ae5d8..f0f1ae7 100644 --- a/help/operators_priority.html +++ b/help/operators_priority.html @@ -22,6 +22,7 @@ ( )parentheses for grouping an expression(1+3)*4 - + # &unary minus and plus, and operators for changing the base (radix)-10 +without an operatorshort form of multiplicating (only if the second argument is a variable or function)3y ^powering3^2 * /multiplication and division10*20 + -addition and subtraction10-30 diff --git a/help/userfunctions.html b/help/userfunctions.html index 914245b..53c7f17 100644 --- a/help/userfunctions.html +++ b/help/userfunctions.html @@ -17,9 +17,9 @@

You are allowed to define your own variables and functions. As a name of a variable or a function -can be a name consists of letters and digits but the first character must be a letter. Names are case-insensitive -that means 'name' is the same as 'NaMe'. For example these -are correct names: a, b, c3, myname, etc. During defining variables and functions you can call another +can be a name consists of letters, digits or an underline character but the first character must be a letter. +From version 0.8.3 names are case-sensitive that means 'name' is not the same as 'NaMe'. For example these +are correct names: a, b, c3, MyName, etc. During defining variables and functions you can call another variables and functions but you cannot call a variable or a function twice. Recurrence calling are not allowed.

diff --git a/src/functions.cpp b/src/functions.cpp index 4b4ed3c..3e09373 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -97,10 +97,10 @@ int i; pchar = new char[temporary_buffer_size]; GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_NAME, pchar, temporary_buffer_size); - name = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) ); + name = Variables::StripWhiteCharacters(pchar); GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_VALUE, pchar, temporary_buffer_size); - value = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) ); + value = Variables::StripWhiteCharacters(pchar); parameters = (int)SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_GETCURSEL,0,0); diff --git a/src/iniparser.cpp b/src/iniparser.cpp index 59a1fe9..3692215 100644 --- a/src/iniparser.cpp +++ b/src/iniparser.cpp @@ -44,6 +44,26 @@ IniParser::IniParser() { strip_white_characters_from_value = true; convert_value_to_small_letters = true; + section_case_sensitive = false; + pattern_case_sensitive = false; +} + + +void IniParser::ConvertValueToSmallLetters(bool conv) +{ + convert_value_to_small_letters = conv; +} + + +void IniParser::SectionCaseSensitive(bool sens) +{ + section_case_sensitive = sens; +} + + +void IniParser::PatternCaseSensitive(bool sens) +{ + pattern_case_sensitive = sens; } @@ -148,7 +168,10 @@ IniParser::Error IniParser::ReadSection(std::string & section) } while( IsSectionCharacter( (c = ReadCharacter()) ) ) - section += LowerCase(c); + if( section_case_sensitive ) + section += c; + else + section += LowerCase(c); if( c != ']' ) { @@ -220,7 +243,11 @@ IniParser::Error IniParser::ReadExpression(std::string & pattern, std::string & while( IsPatternCharacter(c) ) { - pattern += LowerCase(c); + if( pattern_case_sensitive ) + pattern += c; + else + pattern += LowerCase(c); + c = ReadCharacter(); } diff --git a/src/iniparser.h b/src/iniparser.h index d975d72..a687eee 100644 --- a/src/iniparser.h +++ b/src/iniparser.h @@ -133,6 +133,34 @@ public: Error ReadFromFile(const char * path); + + /*! + when true the names of sections will be case-sensitive + e.g. + when true: '[foo]' is not equal '[Foo]' + + default: false + */ + void SectionCaseSensitive(bool sens); + + + /*! + when true the names of patterns will be case-sensitive + e.g. + when true: 'foo = 4' is not equal 'Foo = 4' + + default: false + */ + void PatternCaseSensitive(bool sens); + + + /*! + if conv=true (default) that the whole characters in a value + will be changed into small letters + */ + void ConvertValueToSmallLetters(bool conv); + + private: typedef std::map Table; @@ -144,6 +172,8 @@ private: int line; bool strip_white_characters_from_value; bool convert_value_to_small_letters; + bool section_case_sensitive; + bool pattern_case_sensitive; Error Read(); Error ReadSection(std::string & section); diff --git a/src/languages.cpp b/src/languages.cpp index ebc7613..acfd6f3 100644 --- a/src/languages.cpp +++ b/src/languages.cpp @@ -283,8 +283,8 @@ void Languages::InitGuiMessagesTab() "Mathematical calculator TTCalc %d.%d.%d%s%s\r\n" "Author: Tomasz Sowa\r\n" "Contact: t.sowa@slimaczek.pl\r\n" - "Licence: (New) BSD licence\r\n" - "Project page: http://sourceforge.net/projects/ttcalc\r\n" + "Licence: BSD (open source)\r\n" + "Project page: http://ttcalc.sourceforge.net\r\n" "Bignum library: TTMath %d.%d.%d%s\r\n" "Programming language: C++\r\n" "Compiler: %s\r\n" @@ -406,8 +406,8 @@ void Languages::InitGuiMessagesTab() "Kalkulator matematyczny TTCalc %d.%d.%d%s%s\r\n" "Autor: Tomasz Sowa\r\n" "Kontakt: t.sowa@slimaczek.pl\r\n" - "Licencja: (New) BSD\r\n" - "Strona projektu: http://sourceforge.net/projects/ttcalc\r\n" + "Licencja: BSD (open source)\r\n" + "Strona projektu: http://ttcalc.sourceforge.net\r\n" "Biblioteka dużych liczb: TTMath %d.%d.%d%s\r\n" "Język programowania: C++\r\n" "Kompilator: %s\r\n" diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0c09801..5c48b2a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1038,7 +1038,8 @@ SHELLEXECUTEINFO exec; exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS; exec.hwnd = 0; exec.lpVerb = "open"; - exec.lpFile = "http://sourceforge.net/projects/ttcalc"; + //exec.lpFile = "http://sourceforge.net/projects/ttcalc"; + exec.lpFile = "http://ttcalc.sourceforge.net"; exec.lpParameters = 0; exec.lpDirectory = ""; exec.nShow = SW_SHOWNORMAL; diff --git a/src/programresources.cpp b/src/programresources.cpp index 44d0428..6414b26 100644 --- a/src/programresources.cpp +++ b/src/programresources.cpp @@ -604,6 +604,11 @@ IniParser::Section temp_variables, temp_functions; IniParser::Section::iterator ic; std::string ini_value[20]; + iparser.ConvertValueToSmallLetters(false); + iparser.SectionCaseSensitive(false); + + // we have variables and functions case-sensitive + iparser.PatternCaseSensitive(true); iparser.Associate( "global|always.on.top", &ini_value[0] ); iparser.Associate( "global|view", &ini_value[1] ); diff --git a/src/variables.cpp b/src/variables.cpp index 73f686a..d185b9c 100644 --- a/src/variables.cpp +++ b/src/variables.cpp @@ -109,10 +109,10 @@ char * pchar; pchar = new char[temporary_buffer_size]; GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_NAME, pchar, temporary_buffer_size); - name = ChangeToSmallLetters( StripWhiteCharacters(pchar) ); + name = StripWhiteCharacters(pchar); GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_VALUE, pchar, temporary_buffer_size); - value = ChangeToSmallLetters( StripWhiteCharacters(pchar) ); + value = StripWhiteCharacters(pchar); delete [] pchar;