summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Murchison <murch@andrew.cmu.edu>2017-02-12 19:20:35 -0500
committerKen Murchison <murch@andrew.cmu.edu>2017-02-12 19:20:35 -0500
commit49a3fc532e40b8038ccb78421124d1f9c3bb6d79 (patch)
treed6f69204e2ebc47f9cd8fad60f38999ab1050504
parentccea1834e7aa1dfe217a5697ad5a19704733950e (diff)
parentfda72883c70f289ba7a87d8c59f2751ebd3178a6 (diff)
downloadlibical-git-49a3fc532e40b8038ccb78421124d1f9c3bb6d79.tar.gz
Merge branch 'vpatch' of github.com:libical/libical into vpatch
-rw-r--r--CMakeLists.txt25
-rw-r--r--Install.txt8
-rw-r--r--ReleaseNotes.txt9
-rw-r--r--cmake/Toolchain-Linux-GCC-i686.cmake4
-rw-r--r--cmake/Toolchain-OSX-GCC-i686.cmake4
-rw-r--r--cmake/modules/GObjectIntrospectionMacros.cmake5
-rw-r--r--design-data/parameters.csv4
-rw-r--r--design-data/properties.csv2
-rw-r--r--design-data/restrictions.csv10
-rw-r--r--doc/reference/libical-glib/CMakeLists.txt2
-rw-r--r--examples/CMakeLists.txt18
-rw-r--r--libical.pc.in6
-rwxr-xr-xscripts/mkderivedvalues.pl9
-rw-r--r--src/libical-glib/CMakeLists.txt4
-rw-r--r--src/libical-glib/tools/generator.c17
-rw-r--r--src/libical/CMakeLists.txt51
-rw-r--r--src/libical/icalarray.c1
-rw-r--r--src/libical/icalcomponent.c9
-rw-r--r--src/libical/icalderivedparameter.c.in2
-rw-r--r--src/libical/icalderivedproperty.c.in7
-rw-r--r--src/libical/icalderivedvalue.c.in3
-rw-r--r--src/libical/icalerror.c2
-rw-r--r--src/libical/icalmemory.c1
-rw-r--r--src/libical/icalmime.c24
-rw-r--r--src/libical/icalmime.h3
-rw-r--r--src/libical/icalparameter.c5
-rw-r--r--src/libical/icalparameter.h2
-rw-r--r--src/libical/icalparameter_cxx.cpp42
-rw-r--r--src/libical/icalparameter_cxx.h274
-rw-r--r--src/libical/icalparser.c19
-rw-r--r--src/libical/icalproperty_cxx.cpp159
-rw-r--r--src/libical/icalproperty_cxx.h520
-rw-r--r--src/libical/icalrecur.c4
-rw-r--r--src/libical/icalrestriction.c.in27
-rw-r--r--src/libical/icaltime.c2
-rw-r--r--src/libical/icaltimezone.c11
-rw-r--r--src/libical/icaltz-util.c1
-rw-r--r--src/libical/icalvalue.c59
-rw-r--r--src/libical/icalvalue.h3
-rw-r--r--src/libical/icalvalue_cxx.cpp39
-rw-r--r--src/libical/icalvalue_cxx.h200
-rw-r--r--src/libical/icptrholder_cxx.h19
-rw-r--r--src/libical/vcomponent_cxx.cpp104
-rw-r--r--src/libical/vcomponent_cxx.h444
-rw-r--r--src/libicalss/icalbdbset.c27
-rw-r--r--src/libicalss/icaldirset.c1
-rw-r--r--src/libicalss/icalfileset.c29
-rw-r--r--src/libicalss/icalmessage.c13
-rw-r--r--src/libicalss/icalset.c30
-rw-r--r--src/libicalss/icalspanlist.c3
-rw-r--r--src/libicalss/icalspanlist.h9
-rw-r--r--src/libicalss/icalspanlist_cxx.cpp26
-rw-r--r--src/libicalss/icalspanlist_cxx.h42
-rw-r--r--src/libicalss/icalsslexer.c8
-rw-r--r--src/libicalvcal/vcc.c4
-rw-r--r--src/python/LibicalWrap.i9
-rw-r--r--src/test/CMakeLists.txt63
-rw-r--r--src/test/icalrecur_test.c2
-rw-r--r--src/test/icaltestparser.c4
-rw-r--r--src/test/process.c7
-rw-r--r--src/test/regression-classify.c2
-rw-r--r--src/test/regression-cxx.cpp43
-rw-r--r--src/test/regression-storage.c10
-rw-r--r--src/test/regression-utils.c1
-rw-r--r--src/test/regression.c96
-rw-r--r--src/test/regression.h1
-rw-r--r--src/test/stow.c43
-rw-r--r--src/test/testmime.c3
-rw-r--r--src/test/testvcal.c1
-rw-r--r--src/test/timezones.c5
-rw-r--r--test-data/issue250.ics8
-rw-r--r--test-data/issue251.ics15
-rw-r--r--test-data/issue252.icsbin0 -> 5572 bytes
-rw-r--r--test-data/issue253.icsbin0 -> 7199 bytes
74 files changed, 1391 insertions, 1278 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0173e1a8..0f6dfc34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,7 @@ endif()
# RSCALE info at http://tools.ietf.org/html/rfc7529
find_package(ICU)
if(ICU_FOUND)
+ set(REQUIRES_PRIVATE_ICU "Requires.private: icu-i18n") #for libical.pc
set(HAVE_LIBICU 1)
if(ICU_MAJOR_VERSION VERSION_GREATER 50)
set(HAVE_ICU_DANGI TRUE)
@@ -164,7 +165,8 @@ if(WIN32)
if(USE_32BIT_TIME_T)
add_definitions(-D_USE_32BIT_TIME_T)
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4290")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4290") #C++ exception specification ignored
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4068") #unknown pragma
endif()
add_definitions(-DBIG_ENDIAN=0 -DLITTLE_ENDIAN=1 -DBYTE_ORDER=BIG_ENDIAN)
endif()
@@ -249,7 +251,7 @@ if(GOBJECT_INTROSPECTION)
if(INTROSPECTION_FOUND)
set(HAVE_INTROSPECTION TRUE)
if(STATIC_ONLY)
- message(FATAL_ERROR "You are attempting to build with GObject Introspection enabled, however that option is not supported when building static libraries only. Please disable the static only option to CMake (-DSTATIC_ONLY=False) if you really want to build with GObject Introspection. Alternatively, you can disable Gobject Introspection (by passing -DGOBJECT_INTROSPECTION=False to CMake)")
+ message(FATAL_ERROR "You are attempting to build with GObject Introspection enabled, however that option is not supported when building static libraries only. Please disable the static only option to CMake (-DSTATIC_ONLY=False) if you really want to build with GObject Introspection. Alternatively, you can disable GObject Introspection (by passing -DGOBJECT_INTROSPECTION=False to CMake)")
endif()
else()
message(FATAL_ERROR "You requested to build with GObject Introspection but the necessary development package is missing or too low a version (version ${MIN_GOBJECT_INTROSPECTION} or higher is required)")
@@ -282,7 +284,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
check_c_compiler_flag(-Wlogical-op HAVE_GCC_LOGICAL_OP)
check_c_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GCC_POINTER_MEMACCESS)
check_c_compiler_flag(-Wformat-security HAVE_GCC_FORMAT_SECURITY)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated -Wall -Wextra -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type")
+ check_c_compiler_flag(-Wredundant-decls HAVE_GCC_REDUNDANT_DECLS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated -Wall -Wno-unknown-pragmas -Wextra -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type")
if(HAVE_GCC_UNUSED_BUT_SET)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable")
endif()
@@ -295,6 +298,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
if(HAVE_GCC_FORMAT_SECURITY)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat -Wformat-security")
endif()
+ if(HAVE_GCC_REDUNDANT_DECLS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls")
+ endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_GNU_SOURCE")
endif()
@@ -310,6 +316,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
check_cxx_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GXX_POINTER_MEMACCESS)
check_cxx_compiler_flag(-Wreorder HAVE_GXX_REORDER)
check_cxx_compiler_flag(-Wformat-security HAVE_GXX_FORMAT_SECURITY)
+ check_cxx_compiler_flag(-Wredundant-decls HAVE_GXX_REDUNDANT_DECLS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Weffc++ -Wno-deprecated -Wall -Wextra -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type")
if(HAVE_GXX_UNUSED_BUT_SET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable")
@@ -326,6 +333,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(HAVE_GXX_FORMAT_SECURITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security")
endif()
+ if(HAVE_GXX_REDUNDANT_DECLS)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-decls")
+ endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_GNU_SOURCE")
endif()
@@ -351,11 +361,18 @@ if(ADDRESS_SANITIZER)
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")
- set(ICAL_GLIB False)
else()
message(FATAL_ERROR
"You are trying to build with the address sanitizer using a non-GCC or Clang compiler.")
endif()
+ if(GOBJECT_INTROSPECTION)
+ message(STATUS "Warning: Building the address sanitizer with GObject Introspection is is not supported. Turning-off GObject Introspection")
+ set(HAVE_INTROSPECTION False)
+ endif()
+ if(ICAL_GLIB)
+ message(STATUS "Warning: Building the address sanitizer with the GObject interface is not supported. Turning-off the GObject interface")
+ set(ICAL_GLIB False)
+ endif()
endif()
########################################################
diff --git a/Install.txt b/Install.txt
index bab976b6..c8c8ccad 100644
--- a/Install.txt
+++ b/Install.txt
@@ -98,6 +98,12 @@ Then you can set the C and C++ compilers at CMake time, like so:
need to have the GObject Introspection development package v0.6.7 or higher
installed beforehand.
+You can also force CMake to ignore any of the optional dependencies
+by passing the option -DCMAKE_DISABLE_FIND_PACKAGE_<PACKAGE>=True.
+For instance:
+# tell cmake to ignore ICU
+ % cmake -DCMAKE_DISABLE_FIND_PACKAGE_ICU=True
+
== Language Bindings ==
This C library can be built with bindings for these other languages:
* C++. By default the buildsystem will create and install the C++ bindings API.
@@ -108,7 +114,7 @@ This C library can be built with bindings for these other languages:
== Tweaking the Library Behavior ==
Use these CMake options to adjust the library behavior as follows:
- * ICAL_ERRORS_ARE_FATALL=[true|false]
+ * ICAL_ERRORS_ARE_FATAL=[true|false]
Set to make icalerror_* calls abort instead of internally signaling an error.
Default=false
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index 9b590eb8..67cba70e 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -1,10 +1,15 @@
Release Highlights
==================
+Version 2.1.0:
+--------------
+ * icalvalue_as_ical_string() returns "TRUE" (non-zero) or "FALSE" (zero) values only.
+ * new icalvalue.h convenience macros: ICAL_BOOLEAN_TRUE and ICAL_BOOLEAN_FALSE
+
Version 2.0.0:
--------------
* WARNING: Version 2 IS NOT Binary Compatible with Older Versions
- * Version 2 is Source Compatible with Older Versions
+ * Version 2 is Source Compatible with Older Versions
* Lots of source code scrubbing
* [New] RSCALE support (requires libicu from http://www.icu-project.org)
* [New] CalDAV attachment support (draft-daboo-caldav-attachments)
@@ -41,5 +46,3 @@ Version 1.0.1:
* [Quality] More regression tests added, in particular for recurrence
* [Quality] Almost all compile warnings silenced
* [Quality] A bunch of Coverity Scan warnings silenced
-
-
diff --git a/cmake/Toolchain-Linux-GCC-i686.cmake b/cmake/Toolchain-Linux-GCC-i686.cmake
index 852a6c20..4fe6d1c0 100644
--- a/cmake/Toolchain-Linux-GCC-i686.cmake
+++ b/cmake/Toolchain-Linux-GCC-i686.cmake
@@ -33,5 +33,5 @@
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "i686")
-set(CMAKE_C_COMPILER_ARG1 "-m32")
-set(CMAKE_CXX_COMPILER_ARG1 "-m32")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
diff --git a/cmake/Toolchain-OSX-GCC-i686.cmake b/cmake/Toolchain-OSX-GCC-i686.cmake
index 7323bce8..42644b01 100644
--- a/cmake/Toolchain-OSX-GCC-i686.cmake
+++ b/cmake/Toolchain-OSX-GCC-i686.cmake
@@ -33,5 +33,5 @@
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_SYSTEM_PROCESSOR "i686")
-set(CMAKE_C_COMPILER_ARG1 "-m32")
-set(CMAKE_CXX_COMPILER_ARG1 "-m32")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
diff --git a/cmake/modules/GObjectIntrospectionMacros.cmake b/cmake/modules/GObjectIntrospectionMacros.cmake
index 365bb00b..33e2c0f9 100644
--- a/cmake/modules/GObjectIntrospectionMacros.cmake
+++ b/cmake/modules/GObjectIntrospectionMacros.cmake
@@ -50,7 +50,8 @@ macro(gir_add_introspections introspections_girs)
set(_gir_libtool "--no-libtool")
add_custom_command(
- COMMAND ${INTROSPECTION_SCANNER}
+ COMMAND ${CMAKE_COMMAND} -E env "CC='${CMAKE_C_COMPILER}'"
+ ${INTROSPECTION_SCANNER}
${INTROSPECTION_SCANNER_ARGS}
--namespace=${_gir_namespace}
--nsversion=${_gir_version}
@@ -85,7 +86,7 @@ macro(gir_add_introspections introspections_girs)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION lib/girepository-1.0)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${LIB_INSTALL_DIR}/girepository-1.0)
endforeach()
diff --git a/design-data/parameters.csv b/design-data/parameters.csv
index 4203a0a2..cfa82c78 100644
--- a/design-data/parameters.csv
+++ b/design-data/parameters.csv
@@ -46,7 +46,7 @@
"RESPONSE","38","int",
"REQUIRED","43","icalparameter_required","X=21000;TRUE;FALSE;NONE=21099"
"STAY-INFORMED","39","icalparameter_stayinformed","X=21500;TRUE;FALSE;NONE=21599"
-"#CalDAV Managed Attachment Parameters","draft-daboo-caldav-attachments"
+"#CalDAV Managed Attachment Parameters","draft-ietf-calext-caldav-attachments"
"MANAGED-ID","40","const char*",
"SIZE","41","const char*",
"FILENAME","42","const char*",
@@ -54,7 +54,7 @@
"REASON","43","const char*",
"MODIFIED","44","const char*",
"SUBSTATE","45","icalparameter_substate",X=21900;OK;ERROR;SUSPENDED;NONE=21999",
-"#New Properties for iCalendar","draft-ietf-calext-extensions Section 6"
+"#Parameters from New Properties for iCalendar","RFC 7986 Section 6"
"DISPLAY","46","icalparameter_display",X=22000;BADGE;GRAPHIC;FULLSIZE;THUMBNAIL;NONE=22099",
"EMAIL","47","const char*",
"FEATURE","48","icalparameter_feature",X=22100;AUDIO;CHAT;FEED;MODERATOR;PHONE;SCREEN;VIDEO;NONE=22199",
diff --git a/design-data/properties.csv b/design-data/properties.csv
index c1093ca6..e0ee79e7 100644
--- a/design-data/properties.csv
+++ b/design-data/properties.csv
@@ -129,7 +129,7 @@
"#Task Extension Properties","draft-apthorp-ical-tasks",
"ESTIMATED-DURATION","113","DURATION","DURATION"
"TASK-MODE","114","TASKMODE","TASKMODE"
-"#New Properties for iCalendar","draft-ietf-calext-extensions Section 5",
+"#New Properties for iCalendar","RFC 7986 Section 5",
"NAME","115","TEXT","TEXT"
"REFRESH-INTERVAL","116","DURATION","DURATION"
"SOURCE","117","URI","URI"
diff --git a/design-data/restrictions.csv b/design-data/restrictions.csv
index 05188d4d..8ac93764 100644
--- a/design-data/restrictions.csv
+++ b/design-data/restrictions.csv
@@ -893,13 +893,13 @@ NONE,VCALENDAR,ATTACH,NONE,ZERO
NONE,VCALENDAR,ATTENDEE,NONE,ZERO
NONE,VCALENDAR,RELCALID,NONE,ZEROORONE
NONE,VCALENDAR,CALSCALE,NONE,ZEROORONE
-NONE,VCALENDAR,CATEGORIES,NONE,ZERO
+NONE,VCALENDAR,CATEGORIES,NONE,ZEROPLUS
NONE,VCALENDAR,CLASS,NONE,ZERO
NONE,VCALENDAR,COMMENT,NONE,ZERO
NONE,VCALENDAR,COMPLETED,NONE,ZERO
NONE,VCALENDAR,CONTACT,NONE,ZERO
NONE,VCALENDAR,CREATED,NONE,ZERO
-NONE,VCALENDAR,DESCRIPTION,NONE,ZERO
+NONE,VCALENDAR,DESCRIPTION,NONE,ZEROPLUS
NONE,VCALENDAR,DTEND,NONE,ZERO
NONE,VCALENDAR,DTSTAMP,NONE,ZERO
NONE,VCALENDAR,DTSTART,NONE,ZERO
@@ -909,7 +909,7 @@ NONE,VCALENDAR,EXDATE,NONE,ZERO
NONE,VCALENDAR,EXRULE,NONE,ZERO
NONE,VCALENDAR,FREEBUSY,NONE,ZERO
NONE,VCALENDAR,GEO,NONE,ZERO
-NONE,VCALENDAR,LASTMODIFIED,NONE,ZERO
+NONE,VCALENDAR,LASTMODIFIED,NONE,ZEROORONE
NONE,VCALENDAR,LOCATION,NONE,ZERO
NONE,VCALENDAR,METHOD,NONE,ZEROORONE
NONE,VCALENDAR,ORGANIZER,NONE,ZERO
@@ -933,8 +933,8 @@ NONE,VCALENDAR,TZNAME,NONE,ZERO
NONE,VCALENDAR,TZOFFSETFROM,NONE,ZERO
NONE,VCALENDAR,TZOFFSETTO,NONE,ZERO
NONE,VCALENDAR,TZURL,NONE,ZERO
-NONE,VCALENDAR,UID,NONE,ZERO
-NONE,VCALENDAR,URL,NONE,ZERO
+NONE,VCALENDAR,UID,NONE,ZEROORONE
+NONE,VCALENDAR,URL,NONE,ZEROORONE
NONE,VCALENDAR,VERSION,NONE,ONE
NONE,VCALENDAR,X,NONE,ZEROPLUS
NONE,VCALENDAR,COLOR,NONE,ZEROORONE
diff --git a/doc/reference/libical-glib/CMakeLists.txt b/doc/reference/libical-glib/CMakeLists.txt
index a3879773..d3fdbaaa 100644
--- a/doc/reference/libical-glib/CMakeLists.txt
+++ b/doc/reference/libical-glib/CMakeLists.txt
@@ -85,4 +85,4 @@ add_custom_target(documentation ALL
add_dependencies(documentation ical-glib)
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${OUTPUT_DOCDIR} PATTERN "html/*")
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION ${OUTPUT_DOCDIR})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 32942d99..7ba11f50 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -23,19 +23,11 @@ add_dependencies(doesnothing ical icalss icalvcal)
if(NOT STATIC_ONLY)
target_link_libraries(doesnothing ical icalss icalvcal)
else()
- if(NOT WIN32)
- target_link_libraries(doesnothing
- ${CMAKE_BINARY_DIR}/lib/libical.a
- ${CMAKE_BINARY_DIR}/lib/libicalss.a
- ${CMAKE_BINARY_DIR}/lib/libicalvcal.a
- )
- else()
- target_link_libraries(doesnothing
- ${CMAKE_BINARY_DIR}/bin/libical-static.lib
- ${CMAKE_BINARY_DIR}/bin/libicalss-static.lib
- ${CMAKE_BINARY_DIR}/bin/libicalvcal-static.lib
- )
- endif()
+ target_link_libraries(doesnothing
+ ical-static
+ icalss-static
+ icalvcal-static
+ )
target_link_libraries(doesnothing ${CMAKE_THREAD_LIBS_INIT})
if(ICU_FOUND)
target_link_libraries(doesnothing ${ICU_LIBRARY})
diff --git a/libical.pc.in b/libical.pc.in
index 5c2debd8..c07eb52a 100644
--- a/libical.pc.in
+++ b/libical.pc.in
@@ -2,11 +2,11 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
-threadslib=@PTHREAD_LIBS@
-iculib=@ICU_LIBRARIES@ @ICU_I18N_LIBRARIES@
Name: libical
Description: An implementation of basic iCAL protocols
Version: @LIBICAL_LIB_VERSION_STRING@
-Libs: -L${libdir} -lical -licalss -licalvcal ${threadslib} ${iculib}
+Libs: -L${libdir} -lical -licalss -licalvcal
+Libs.private: @PTHREAD_LIBS@
+@REQUIRES_PRIVATE_ICU@
Cflags: -I${includedir}
diff --git a/scripts/mkderivedvalues.pl b/scripts/mkderivedvalues.pl
index f74f16e7..f429dd12 100755
--- a/scripts/mkderivedvalues.pl
+++ b/scripts/mkderivedvalues.pl
@@ -45,6 +45,11 @@ if ($opt_i) {
}
}
+
+ if ($opt_h) {
+ print "#endif /*ICALVALUE_H*/\n";
+ }
+
}
sub insert_code
@@ -264,8 +269,4 @@ LIBICAL_ICAL_EXPORT void icalvalue_set_${lc}(icalvalue *value, ${type} v);\n";
}
- if ($opt_h) {
- print "#endif /*ICALVALUE_H*/\n";
- }
-
}
diff --git a/src/libical-glib/CMakeLists.txt b/src/libical-glib/CMakeLists.txt
index 5ad775ad..0006f3d5 100644
--- a/src/libical-glib/CMakeLists.txt
+++ b/src/libical-glib/CMakeLists.txt
@@ -67,8 +67,8 @@ endforeach()
add_custom_command (
OUTPUT ${LIBICAL_GLIB_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/libical-glib-private.h ${CMAKE_CURRENT_BINARY_DIR}/i-cal-forward-declarations.h
- COMMAND src-generator "${CMAKE_CURRENT_SOURCE_DIR}/tools" "${CMAKE_CURRENT_SOURCE_DIR}/api"
- DEPENDS src-generator ${xml_files}
+ COMMAND ${EXECUTABLE_OUTPUT_PATH}/src-generator "${CMAKE_CURRENT_SOURCE_DIR}/tools" "${CMAKE_CURRENT_SOURCE_DIR}/api"
+ DEPENDS ${EXECUTABLE_OUTPUT_PATH}/src-generator ${xml_files}
)
configure_file(
diff --git a/src/libical-glib/tools/generator.c b/src/libical-glib/tools/generator.c
index 3742c685..b0a38a77 100644
--- a/src/libical-glib/tools/generator.c
+++ b/src/libical-glib/tools/generator.c
@@ -299,9 +299,10 @@ gchar *get_lower_train_from_lower_snake(const gchar *lowerSnake)
{
guint i;
gchar *ret;
- guint len = (guint) strlen(lowerSnake);
+ guint len;
g_return_val_if_fail(lowerSnake != NULL && *lowerSnake != '\0', NULL);
+ len = (guint) strlen(lowerSnake);
ret = g_strdup(lowerSnake);
for (i = 0; i < len; i++) {
@@ -984,8 +985,6 @@ void generate_header_includes(FILE *out, Structure *structure)
write_str(out, COMMON_HEADER);
write_str(out, ".h>\n");
- g_return_if_fail(out != NULL && structure != NULL);
-
includeNames = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
upperCamel = g_strconcat(structure->nameSpace, structure->name, NULL);
@@ -1280,7 +1279,7 @@ void generate_conditional(FILE *out, Structure *structure, gchar *statement, GHa
gchar c;
gchar *var;
gchar *val;
- guint statement_len = (guint) strlen(statement);
+ guint statement_len;
guint expression_len;
g_return_if_fail(out != NULL && structure != NULL && statement != NULL && *statement != '\0');
@@ -1289,6 +1288,7 @@ void generate_conditional(FILE *out, Structure *structure, gchar *statement, GHa
count = 0;
isNegate = FALSE;
isTrue = FALSE;
+ statement_len = (guint) strlen(statement);
if (statement[0] == '!') {
isNegate = TRUE;
@@ -1682,7 +1682,7 @@ gchar *get_source_method_body(Method *method, const gchar *nameSpace)
g_free(checkers);
}
- /*op on the owner */
+ /* op on the owner */
/* TODO: Change the translatorArgus in Parameter to parent */
for (iter = g_list_first(method->parameters); iter != NULL; iter = g_list_next(iter)) {
parameter = (Parameter *) iter->data;
@@ -1965,8 +1965,9 @@ void generate_header_enum(FILE *out, Enumeration *enumeration)
enumeration->name);
}
- /*Generate the comment block */
+ /* Generate the comment block */
if (enumeration->comment != NULL) {
+ //krazy:cond=style
comment = g_strdup("/**");
tmp = g_strconcat(comment, "\n * ", enumeration->name, ":", NULL);
g_free(comment);
@@ -1979,14 +1980,14 @@ void generate_header_enum(FILE *out, Enumeration *enumeration)
tmp = g_strconcat(comment, "\n */\n", NULL);
g_free(comment);
comment = tmp;
-
+ //krazy:endcond=style
write_str(out, comment);
g_free(comment);
comment = NULL;
tmp = NULL;
}
- /*Generate the declaration */
+ /* Generate the declaration */
write_str(out, "typedef enum {");
for (iter = g_list_first(enumeration->elements); iter != NULL; iter = g_list_next(iter)) {
diff --git a/src/libical/CMakeLists.txt b/src/libical/CMakeLists.txt
index 369b089e..b50d47e4 100644
--- a/src/libical/CMakeLists.txt
+++ b/src/libical/CMakeLists.txt
@@ -317,39 +317,40 @@ if(WITH_CXX_BINDINGS)
add_definitions(-DBUILD_LIBICALDLL)
- if(NOT STATIC_ONLY)
- add_library(ical_cxx SHARED ${icalcxx_LIB_SRCS})
- add_dependencies(ical_cxx ical-header)
- target_link_libraries(ical_cxx ical ${CMAKE_THREAD_LIBS_INIT})
- if(WINCE)
- target_link_libraries(ical_cxx ${WCECOMPAT_LIBRARIES})
- endif()
- if(MSVC)
- set_target_properties(ical_cxx PROPERTIES OUTPUT_NAME "libical_cxx")
- endif()
- set_target_properties(ical_cxx PROPERTIES
- VERSION ${LIBICAL_LIB_VERSION_STRING}
- SOVERSION ${LIBICAL_LIB_MAJOR_VERSION}
- )
- set_target_properties(ical_cxx PROPERTIES CLEAN_DIRECT_OUTPUT 1)
-
- install(
- TARGETS ical_cxx
- EXPORT icalTargets
- DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}
- )
- endif()
-
+ add_library(ical_cxx ${LIBRARY_TYPE} ${icalcxx_LIB_SRCS})
+ add_dependencies(ical_cxx ical-header)
if(NOT SHARED_ONLY)
add_library(ical_cxx-static STATIC ${icalcxx_LIB_SRCS})
add_dependencies(ical_cxx-static ical-header)
- if(MSVC)
+ endif()
+ target_link_libraries(ical_cxx ical ${CMAKE_THREAD_LIBS_INIT})
+
+ if(MSVC)
+ set_target_properties(ical_cxx PROPERTIES OUTPUT_NAME "libical_cxx")
+ if(NOT SHARED_ONLY)
set_target_properties(ical_cxx-static PROPERTIES OUTPUT_NAME "libical_cxx-static")
- else()
+ endif()
+ else()
+ if(NOT SHARED_ONLY)
set_target_properties(ical_cxx-static PROPERTIES OUTPUT_NAME "ical_cxx")
endif()
+ endif()
+
+ set_target_properties(ical_cxx PROPERTIES
+ VERSION ${LIBICAL_LIB_VERSION_STRING}
+ SOVERSION ${LIBICAL_LIB_MAJOR_VERSION}
+ )
+ set_target_properties(ical_cxx PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ if(NOT SHARED_ONLY)
set_target_properties(ical_cxx-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ endif()
+ install(
+ TARGETS ical_cxx
+ EXPORT icalTargets
+ DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}
+ )
+ if(NOT SHARED_ONLY)
install(
TARGETS ical_cxx-static
EXPORT icalTargets
diff --git a/src/libical/icalarray.c b/src/libical/icalarray.c
index c2b92344..fbb69009 100644
--- a/src/libical/icalarray.c
+++ b/src/libical/icalarray.c
@@ -112,7 +112,6 @@ void icalarray_free(icalarray *array)
array->chunks = 0;
}
free(array);
- array = 0;
}
void icalarray_append(icalarray *array, const void *element)
diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c
index 36e4f665..62674742 100644
--- a/src/libical/icalcomponent.c
+++ b/src/libical/icalcomponent.c
@@ -118,6 +118,9 @@ icalcomponent *icalcomponent_new(icalcomponent_kind kind)
/** @brief Constructor
*/
+//TODO:V3:API:Is there a way to change the API so -Wvarargs doesn't complain?
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvarargs"
icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...)
{
va_list args;
@@ -134,6 +137,7 @@ icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...)
return impl;
}
+#pragma clang diagnostic pop
/** @brief Constructor
*/
@@ -218,8 +222,10 @@ void icalcomponent_free(icalcomponent *c)
free(c->x_name);
}
- if (c->timezones)
+ if (c->timezones) {
icaltimezone_array_free(c->timezones);
+ c->timezones = 0;
+ }
c->kind = ICAL_NO_COMPONENT;
c->properties = 0;
@@ -2038,6 +2044,7 @@ void icalcomponent_merge_component(icalcomponent *comp, icalcomponent *comp_to_m
}
}
icalarray_free(tzids_to_rename);
+ tzids_to_rename = 0;
/* Now move all the components from comp_to_merge to comp, excluding
VTIMEZONE components. */
subcomp = icalcomponent_get_first_component(comp_to_merge, ICAL_ANY_COMPONENT);
diff --git a/src/libical/icalderivedparameter.c.in b/src/libical/icalderivedparameter.c.in
index 5c778006..3da1803d 100644
--- a/src/libical/icalderivedparameter.c.in
+++ b/src/libical/icalderivedparameter.c.in
@@ -33,8 +33,6 @@
#include <stdlib.h>
#include <string.h>
-icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
-
struct icalparameter_impl *icalparameter_new_impl(icalparameter_kind kind);
/* This map associates each of the parameters with the string
diff --git a/src/libical/icalderivedproperty.c.in b/src/libical/icalderivedproperty.c.in
index 75b4da61..04f1851b 100644
--- a/src/libical/icalderivedproperty.c.in
+++ b/src/libical/icalderivedproperty.c.in
@@ -29,9 +29,6 @@
#include <string.h>
-struct icalproperty_impl *icalproperty_new_impl(icalproperty_kind kind);
-void icalproperty_add_parameters(struct icalproperty_impl *prop, va_list args);
-
/* This map associates the property kinds with the string
representation of the property name and the kind of VALUE that the
property uses as a default */
@@ -55,7 +52,11 @@ struct icalproperty_enum_map
const char *str;
};
+//TODO:V3:API:Is there a way to change the API so -Wvarargs doesn't complain?
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvarargs"
<insert_code_here>
+#pragma clang diagnostic pop
int icalproperty_kind_is_valid(const icalproperty_kind kind)
{
diff --git a/src/libical/icalderivedvalue.c.in b/src/libical/icalderivedvalue.c.in
index 38506069..132e3d39 100644
--- a/src/libical/icalderivedvalue.c.in
+++ b/src/libical/icalderivedvalue.c.in
@@ -134,6 +134,7 @@ void icalvalue_set_recur(icalvalue *impl, struct icalrecurrencetype v)
icalerror_check_value_type(value, ICAL_RECUR_VALUE);
if (impl->data.v_recur != 0) {
+ free(impl->data.v_recur->rscale);
free(impl->data.v_recur);
impl->data.v_recur = 0;
}
@@ -145,6 +146,8 @@ void icalvalue_set_recur(icalvalue *impl, struct icalrecurrencetype v)
return;
} else {
memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
+
+ if (v.rscale) impl->data.v_recur->rscale = icalmemory_strdup(v.rscale);
}
}
diff --git a/src/libical/icalerror.c b/src/libical/icalerror.c
index 8702a5ae..1c1e87d1 100644
--- a/src/libical/icalerror.c
+++ b/src/libical/icalerror.c
@@ -86,8 +86,10 @@ void icalerror_crash_here(void)
{
int *p = 0;
/* coverity[var_deref_op] */
+ /* cppcheck-suppress nullPointer */
*p = 1;
+ /* cppcheck-suppress nullPointer */
assert(*p);
}
diff --git a/src/libical/icalmemory.c b/src/libical/icalmemory.c
index e2c7635a..2ad821fb 100644
--- a/src/libical/icalmemory.c
+++ b/src/libical/icalmemory.c
@@ -182,6 +182,7 @@ void icalmemory_add_tmp_buffer(void *buf)
/* Assign the buffer to a slot */
br->ring[br->pos] = buf;
+ /* cppcheck-suppress memleak */
}
/**
diff --git a/src/libical/icalmime.c b/src/libical/icalmime.c
index 3e1f3e12..8418a386 100644
--- a/src/libical/icalmime.c
+++ b/src/libical/icalmime.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#define TMP_BUF_SIZE 1024
+#define TMP_ERR_SIZE 256
/* These *_part routines are called by the MIME parser via the
local_action_map */
@@ -160,8 +161,6 @@ struct sspm_part *icalmime_make_part(icalcomponent *comp)
return 0;
}
-char *icalmime_as_mime_string(char *icalcomponent);
-
icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d), void *data)
{
struct sspm_part *parts;
@@ -202,7 +201,8 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d
if (parts[i].header.error != SSPM_NO_ERROR) {
const char *str = "Unknown error";
- char temp[256];
+ char temp[TMP_ERR_SIZE];
+ icalparameter *errParam;
if (parts[i].header.error == SSPM_MALFORMED_HEADER_ERROR) {
str = "Malformed header, possibly due to input not in MIME format";
@@ -227,24 +227,26 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d
}
if (parts[i].header.error_text != 0) {
- snprintf(temp, 256, "%s: %s", str, parts[i].header.error_text);
+ snprintf(temp, TMP_ERR_SIZE, "%s: %s", str, parts[i].header.error_text);
} else {
strcpy(temp, str);
}
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_MIMEPARSEERROR);
icalcomponent_add_property(
comp,
- icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_MIMEPARSEERROR), 0));
+ icalproperty_vanew_xlicerror(temp, errParam, 0));
+ icalparameter_free(errParam);
}
if (parts[i].header.major != SSPM_NO_MAJOR_TYPE &&
parts[i].header.major != SSPM_UNKNOWN_MAJOR_TYPE) {
+ char *mimeTypeCopy = icalmemory_strdup(mimetype);
icalcomponent_add_property(
comp,
- icalproperty_new_xlicmimecontenttype((char *)icalmemory_strdup(mimetype)));
+ icalproperty_new_xlicmimecontenttype(mimeTypeCopy));
+ free(mimeTypeCopy);
}
if (parts[i].header.encoding != SSPM_NO_ENCODING) {
@@ -283,11 +285,11 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d
parts[i].header.minor != SSPM_CALENDAR_MINOR_TYPE && parts[i].data != 0) {
/* Add other text components as "DESCRIPTION" properties */
-
+ char *descStr = icalmemory_strdup((char *)parts[i].data);
icalcomponent_add_property(
comp,
- icalproperty_new_description((char *)icalmemory_strdup((char *)parts[i].data)));
-
+ icalproperty_new_description(descStr));
+ free(descStr);
parts[i].data = 0;
}
diff --git a/src/libical/icalmime.h b/src/libical/icalmime.h
index fd2dd4ba..95adf09a 100644
--- a/src/libical/icalmime.h
+++ b/src/libical/icalmime.h
@@ -27,7 +27,4 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalmime_parse(char *(*line_gen_func) (char *
size_t size,
void *d), void *data);
-/* The inverse of icalmime_parse, not implemented yet. Use sspm.h directly. */
-LIBICAL_ICAL_EXPORT char *icalmime_as_mime_string(char *component);
-
#endif /* !ICALMIME_H */
diff --git a/src/libical/icalparameter.c b/src/libical/icalparameter.c
index 3ed81ca5..5dab4951 100644
--- a/src/libical/icalparameter.c
+++ b/src/libical/icalparameter.c
@@ -33,9 +33,6 @@
#include <errno.h>
#include <stdlib.h>
-/* In icalderivedparameter */
-icalparameter *icalparameter_new_from_value_string(icalparameter_kind kind, const char *val);
-
LIBICAL_ICAL_EXPORT struct icalparameter_impl *icalparameter_new_impl(icalparameter_kind kind)
{
struct icalparameter_impl *v;
@@ -249,8 +246,6 @@ char *icalparameter_as_ical_string_r(icalparameter *param)
return buf;
}
-int icalparameter_is_valid(icalparameter *parameter);
-
icalparameter_kind icalparameter_isa(icalparameter *parameter)
{
if (parameter == 0) {
diff --git a/src/libical/icalparameter.h b/src/libical/icalparameter.h
index 166dca13..b4e7d600 100644
--- a/src/libical/icalparameter.h
+++ b/src/libical/icalparameter.h
@@ -43,8 +43,6 @@ LIBICAL_ICAL_EXPORT char *icalparameter_as_ical_string(icalparameter *parameter)
LIBICAL_ICAL_EXPORT char *icalparameter_as_ical_string_r(icalparameter *parameter);
-LIBICAL_ICAL_EXPORT int icalparameter_is_valid(icalparameter *parameter);
-
LIBICAL_ICAL_EXPORT icalparameter_kind icalparameter_isa(icalparameter *parameter);
LIBICAL_ICAL_EXPORT int icalparameter_isa_parameter(void *param);
diff --git a/src/libical/icalparameter_cxx.cpp b/src/libical/icalparameter_cxx.cpp
index 62a5ed17..83247486 100644
--- a/src/libical/icalparameter_cxx.cpp
+++ b/src/libical/icalparameter_cxx.cpp
@@ -21,12 +21,12 @@
using namespace LibICal;
ICalParameter::ICalParameter() throw(icalerrorenum)
- : imp(icalparameter_new(ICAL_ANY_PARAMETER))
+ : imp(icalparameter_new(ICAL_ANY_PARAMETER))
{
}
ICalParameter::ICalParameter(const ICalParameter &v) throw(icalerrorenum)
- : imp(icalparameter_new_clone(v.imp))
+ : imp(icalparameter_new_clone(v.imp))
{
if (imp == NULL) {
throw icalerrno;
@@ -63,13 +63,13 @@ ICalParameter::~ICalParameter()
}
ICalParameter::ICalParameter(icalparameter *v) throw(icalerrorenum)
- : imp(v)
+ : imp(v)
{
}
/// Create from string of form "PARAMNAME=VALUE"
ICalParameter::ICalParameter(const std::string &str) throw(icalerrorenum)
- : imp(icalparameter_new_from_string(str.c_str()))
+ : imp(icalparameter_new_from_string(str.c_str()))
{
if (imp == NULL) {
throw icalerrno;
@@ -79,7 +79,7 @@ ICalParameter::ICalParameter(const std::string &str) throw(icalerrorenum)
/// Create from just the value, the part after the "="
ICalParameter::ICalParameter(const icalparameter_kind &kind,
const std::string &str) throw(icalerrorenum)
- : imp(icalparameter_new_from_value_string(kind, str.c_str()))
+ : imp(icalparameter_new_from_value_string(kind, str.c_str()))
{
if (imp == NULL) {
throw icalerrno;
@@ -87,7 +87,7 @@ ICalParameter::ICalParameter(const icalparameter_kind &kind,
}
ICalParameter::ICalParameter(const icalparameter_kind &kind) throw(icalerrorenum)
- : imp(icalparameter_new(kind))
+ : imp(icalparameter_new(kind))
{
if (imp == NULL) {
throw icalerrno;
@@ -110,7 +110,7 @@ bool ICalParameter::is_valid()
if (imp == NULL) {
return false;
}
- return (icalparameter_isa_parameter((void *)imp) ? true : false);
+ return (icalparameter_isa_parameter(static_cast<void *>(imp)) != 0);
}
icalparameter_kind ICalParameter::isa()
@@ -131,7 +131,7 @@ void ICalParameter::set_xname(ICalParameter &param, const std::string &v)
std::string ICalParameter::get_xname(ICalParameter &param)
{
- return (std::string)icalparameter_get_xname(param);
+ return static_cast<std::string>(icalparameter_get_xname(param));
}
void ICalParameter::set_xvalue(ICalParameter &param, const std::string &v)
@@ -141,13 +141,13 @@ void ICalParameter::set_xvalue(ICalParameter &param, const std::string &v)
std::string ICalParameter::get_xvalue(ICalParameter &param)
{
- return (std::string)icalparameter_get_xvalue(param);
+ return static_cast<std::string>(icalparameter_get_xvalue(param));
}
/* Convert enumerations */
std::string ICalParameter::kind_to_string(const icalparameter_kind &kind)
{
- return (std::string)icalparameter_kind_to_string(kind);
+ return static_cast<std::string>(icalparameter_kind_to_string(kind));
}
icalparameter_kind ICalParameter::string_to_kind(const std::string &str)
@@ -158,7 +158,7 @@ icalparameter_kind ICalParameter::string_to_kind(const std::string &str)
/* DELEGATED-FROM */
std::string ICalParameter::get_delegatedfrom() const
{
- return (std::string)icalparameter_get_delegatedfrom(imp);
+ return static_cast<std::string>(icalparameter_get_delegatedfrom(imp));
}
void ICalParameter::set_delegatedfrom(const std::string &v)
@@ -180,7 +180,7 @@ void ICalParameter::set_related(const icalparameter_related &v)
/* SENT-BY */
std::string ICalParameter::get_sentby() const
{
- return (std::string)icalparameter_get_sentby(imp);
+ return static_cast<std::string>(icalparameter_get_sentby(imp));
}
void ICalParameter::set_sentby(const std::string &v)
@@ -191,7 +191,7 @@ void ICalParameter::set_sentby(const std::string &v)
/* LANGUAGE */
std::string ICalParameter::get_language() const
{
- return (std::string)icalparameter_get_language(imp);
+ return static_cast<std::string>(icalparameter_get_language(imp));
}
void ICalParameter::set_language(const std::string &v)
@@ -224,7 +224,7 @@ void ICalParameter::set_encoding(const icalparameter_encoding &v)
/* ALTREP */
std::string ICalParameter::get_altrep() const
{
- return (std::string)icalparameter_get_language(imp);
+ return static_cast<std::string>(icalparameter_get_language(imp));
}
void ICalParameter::set_altrep(const std::string &v)
@@ -235,7 +235,7 @@ void ICalParameter::set_altrep(const std::string &v)
/* FMTTYPE */
std::string ICalParameter::get_fmttype() const
{
- return (std::string)icalparameter_get_fmttype(imp);
+ return static_cast<std::string>(icalparameter_get_fmttype(imp));
}
void ICalParameter::set_fmttype(const std::string &v)
@@ -279,7 +279,7 @@ void ICalParameter::set_range(const icalparameter_range &v)
/* DELEGATED-TO */
std::string ICalParameter::get_delegatedto() const
{
- return (std::string)icalparameter_get_delegatedto(imp);
+ return static_cast<std::string>(icalparameter_get_delegatedto(imp));
}
void ICalParameter::set_delegatedto(const std::string &v)
@@ -290,7 +290,7 @@ void ICalParameter::set_delegatedto(const std::string &v)
/* CN */
std::string ICalParameter::get_cn() const
{
- return (std::string)icalparameter_get_cn(imp);
+ return static_cast<std::string>(icalparameter_get_cn(imp));
}
void ICalParameter::set_cn(const std::string &v)
@@ -345,7 +345,7 @@ void ICalParameter::set_xlicerrortype(const icalparameter_xlicerrortype &v)
/* MEMBER */
std::string ICalParameter::get_member() const
{
- return (std::string)icalparameter_get_member(imp);
+ return static_cast<std::string>(icalparameter_get_member(imp));
}
void ICalParameter::set_member(const std::string &v)
@@ -356,7 +356,7 @@ void ICalParameter::set_member(const std::string &v)
/* X */
std::string ICalParameter::get_x() const
{
- return (std::string)icalparameter_get_x(imp);
+ return static_cast<std::string>(icalparameter_get_x(imp));
}
void ICalParameter::set_x(const std::string &v)
@@ -378,7 +378,7 @@ void ICalParameter::set_cutype(const icalparameter_cutype &v)
/* TZID */
std::string ICalParameter::get_tzid() const
{
- return (std::string)icalparameter_get_tzid(imp);
+ return static_cast<std::string>(icalparameter_get_tzid(imp));
}
void ICalParameter::set_tzid(const std::string &v)
@@ -400,7 +400,7 @@ void ICalParameter::set_value(const icalparameter_value &v)
/* DIR */
std::string ICalParameter::get_dir() const
{
- return (std::string)icalparameter_get_dir(imp);
+ return static_cast<std::string>(icalparameter_get_dir(imp));
}
void ICalParameter::set_dir(const std::string &v)
diff --git a/src/libical/icalparameter_cxx.h b/src/libical/icalparameter_cxx.h
index e6d1ad10..8aa7a280 100644
--- a/src/libical/icalparameter_cxx.h
+++ b/src/libical/icalparameter_cxx.h
@@ -34,144 +34,144 @@ extern "C"
namespace LibICal
{
- class LIBICAL_ICAL_EXPORT ICalParameter
+class LIBICAL_ICAL_EXPORT ICalParameter
+{
+public:
+ ICalParameter() throw(icalerrorenum);
+ ICalParameter(const ICalParameter &) throw(icalerrorenum);
+ ICalParameter &operator=(const ICalParameter &) throw(icalerrorenum);
+ ~ICalParameter();
+
+ explicit ICalParameter(icalparameter *v) throw(icalerrorenum);
+
+ // Create from string of form "PARAMNAME=VALUE"
+ explicit ICalParameter(const std::string &str) throw(icalerrorenum);
+
+ // Create from just the value, the part after the "="
+ explicit ICalParameter(const icalparameter_kind &kind) throw(icalerrorenum);
+ ICalParameter(const icalparameter_kind &kind,
+ const std::string &str) throw(icalerrorenum);
+
+ operator icalparameter *()
{
- public:
- ICalParameter() throw(icalerrorenum);
- ICalParameter(const ICalParameter &) throw(icalerrorenum);
- ICalParameter & operator=(const ICalParameter &) throw(icalerrorenum);
- ~ICalParameter();
-
- explicit ICalParameter(icalparameter *v) throw(icalerrorenum);
-
- // Create from string of form "PARAMNAME=VALUE"
- explicit ICalParameter(const std::string & str) throw(icalerrorenum);
-
- // Create from just the value, the part after the "="
- explicit ICalParameter(const icalparameter_kind & kind) throw(icalerrorenum);
- ICalParameter(const icalparameter_kind & kind,
- const std::string & str) throw(icalerrorenum);
-
- operator icalparameter *()
- {
- return imp;
- }
-
- void detach();
-
- public:
- std::string as_ical_string() throw(icalerrorenum);
- bool is_valid();
- icalparameter_kind isa();
- int isa_parameter(void *param);
-
- public:
- /* Access the name of an X parameter */
- static void set_xname(ICalParameter & param, const std::string & v);
- static std::string get_xname(ICalParameter & param);
- static void set_xvalue(ICalParameter & param, const std::string & v);
- static std::string get_xvalue(ICalParameter & param);
-
- /* Convert enumerations */
- static std::string kind_to_string(const icalparameter_kind & kind);
- static icalparameter_kind string_to_kind(const std::string & str);
-
- public:
- /* DELEGATED-FROM */
- std::string get_delegatedfrom() const;
- void set_delegatedfrom(const std::string & v);
-
- /* RELATED */
- icalparameter_related get_related() const;
- void set_related(const icalparameter_related & v);
-
- /* SENT-BY */
- std::string get_sentby() const;
- void set_sentby(const std::string & v);
-
- /* LANGUAGE */
- std::string get_language() const;
- void set_language(const std::string & v);
-
- /* RELTYPE */
- icalparameter_reltype get_reltype() const;
- void set_reltype(const icalparameter_reltype & v);
-
- /* ENCODING */
- icalparameter_encoding get_encoding() const;
- void set_encoding(const icalparameter_encoding & v);
-
- /* ALTREP */
- std::string get_altrep() const;
- void set_altrep(const std::string & v);
-
- /* FMTTYPE */
- std::string get_fmttype() const;
- void set_fmttype(const std::string & v);
-
- /* FBTYPE */
- icalparameter_fbtype get_fbtype() const;
- void set_fbtype(const icalparameter_fbtype & v);
-
- /* RSVP */
- icalparameter_rsvp get_rsvp() const;
- void set_rsvp(const icalparameter_rsvp & v);
-
- /* RANGE */
- icalparameter_range get_range() const;
- void set_range(const icalparameter_range & v);
-
- /* DELEGATED-TO */
- std::string get_delegatedto() const;
- void set_delegatedto(const std::string & v);
-
- /* CN */
- std::string get_cn() const;
- void set_cn(const std::string & v);
-
- /* ROLE */
- icalparameter_role get_role() const;
- void set_role(const icalparameter_role & v);
-
- /* X-LIC-COMPARETYPE */
- icalparameter_xliccomparetype get_xliccomparetype() const;
- void set_xliccomparetype(const icalparameter_xliccomparetype & v);
-
- /* PARTSTAT */
- icalparameter_partstat get_partstat() const;
- void set_partstat(const icalparameter_partstat & v);
-
- /* X-LIC-ERRORTYPE */
- icalparameter_xlicerrortype get_xlicerrortype() const;
- void set_xlicerrortype(const icalparameter_xlicerrortype & v);
-
- /* MEMBER */
- std::string get_member() const;
- void set_member(const std::string & v);
-
- /* X */
- std::string get_x() const;
- void set_x(const std::string & v);
-
- /* CUTYPE */
- icalparameter_cutype get_cutype() const;
- void set_cutype(const icalparameter_cutype & v);
-
- /* TZID */
- std::string get_tzid() const;
- void set_tzid(const std::string & v);
-
- /* VALUE */
- icalparameter_value get_value() const;
- void set_value(const icalparameter_value & v);
-
- /* DIR */
- std::string get_dir() const;
- void set_dir(const std::string & v);
-
- private:
- icalparameter *imp;
- };
+ return imp;
+ }
+
+ void detach();
+
+public:
+ std::string as_ical_string() throw(icalerrorenum);
+ bool is_valid();
+ icalparameter_kind isa();
+ int isa_parameter(void *param);
+
+public:
+ /* Access the name of an X parameter */
+ static void set_xname(ICalParameter &param, const std::string &v);
+ static std::string get_xname(ICalParameter &param);
+ static void set_xvalue(ICalParameter &param, const std::string &v);
+ static std::string get_xvalue(ICalParameter &param);
+
+ /* Convert enumerations */
+ static std::string kind_to_string(const icalparameter_kind &kind);
+ static icalparameter_kind string_to_kind(const std::string &str);
+
+public:
+ /* DELEGATED-FROM */
+ std::string get_delegatedfrom() const;
+ void set_delegatedfrom(const std::string &v);
+
+ /* RELATED */
+ icalparameter_related get_related() const;
+ void set_related(const icalparameter_related &v);
+
+ /* SENT-BY */
+ std::string get_sentby() const;
+ void set_sentby(const std::string &v);
+
+ /* LANGUAGE */
+ std::string get_language() const;
+ void set_language(const std::string &v);
+
+ /* RELTYPE */
+ icalparameter_reltype get_reltype() const;
+ void set_reltype(const icalparameter_reltype &v);
+
+ /* ENCODING */
+ icalparameter_encoding get_encoding() const;
+ void set_encoding(const icalparameter_encoding &v);
+
+ /* ALTREP */
+ std::string get_altrep() const;
+ void set_altrep(const std::string &v);
+
+ /* FMTTYPE */
+ std::string get_fmttype() const;
+ void set_fmttype(const std::string &v);
+
+ /* FBTYPE */
+ icalparameter_fbtype get_fbtype() const;
+ void set_fbtype(const icalparameter_fbtype &v);
+
+ /* RSVP */
+ icalparameter_rsvp get_rsvp() const;
+ void set_rsvp(const icalparameter_rsvp &v);
+
+ /* RANGE */
+ icalparameter_range get_range() const;
+ void set_range(const icalparameter_range &v);
+
+ /* DELEGATED-TO */
+ std::string get_delegatedto() const;
+ void set_delegatedto(const std::string &v);
+
+ /* CN */
+ std::string get_cn() const;
+ void set_cn(const std::string &v);
+
+ /* ROLE */
+ icalparameter_role get_role() const;
+ void set_role(const icalparameter_role &v);
+
+ /* X-LIC-COMPARETYPE */
+ icalparameter_xliccomparetype get_xliccomparetype() const;
+ void set_xliccomparetype(const icalparameter_xliccomparetype &v);
+
+ /* PARTSTAT */
+ icalparameter_partstat get_partstat() const;
+ void set_partstat(const icalparameter_partstat &v);
+
+ /* X-LIC-ERRORTYPE */
+ icalparameter_xlicerrortype get_xlicerrortype() const;
+ void set_xlicerrortype(const icalparameter_xlicerrortype &v);
+
+ /* MEMBER */
+ std::string get_member() const;
+ void set_member(const std::string &v);
+
+ /* X */
+ std::string get_x() const;
+ void set_x(const std::string &v);
+
+ /* CUTYPE */
+ icalparameter_cutype get_cutype() const;
+ void set_cutype(const icalparameter_cutype &v);
+
+ /* TZID */
+ std::string get_tzid() const;
+ void set_tzid(const std::string &v);
+
+ /* VALUE */
+ icalparameter_value get_value() const;
+ void set_value(const icalparameter_value &v);
+
+ /* DIR */
+ std::string get_dir() const;
+ void set_dir(const std::string &v);
+
+private:
+ icalparameter *imp;
+};
} // namespace LibICal
diff --git a/src/libical/icalparser.c b/src/libical/icalparser.c
index 43e3516d..998bc96d 100644
--- a/src/libical/icalparser.c
+++ b/src/libical/icalparser.c
@@ -147,8 +147,8 @@ static char *parser_get_next_char(char c, char *str, int qm)
char next_char = *p;
char prev_char = 0;
- while (next_char != 0) {
- if (prev_char != '\\') {
+ while (next_char != '\0') {
+ if ((prev_char != '\0') && (prev_char != '\\')) {
if (qm == 1 && next_char == '"') {
/* Encountered a quote, toggle quote mode */
quote_mode = !quote_mode;
@@ -170,14 +170,14 @@ static char *parser_get_next_char(char c, char *str, int qm)
static char *make_segment(char *start, char *end)
{
char *buf, *tmp;
- size_t size = (size_t) end - (size_t) start;
+ ptrdiff_t size = (ptrdiff_t)(end - start);
- buf = icalmemory_new_buffer(size + 1);
+ buf = icalmemory_new_buffer((size_t)(size + 1));
strncpy(buf, start, size);
*(buf + size) = 0;
tmp = (buf + size);
- while ((tmp >= buf) && ((*tmp == '\0') || iswspace((wint_t) * tmp))) {
+ while ((tmp >= buf) && ((*tmp == '\0') || iswspace((wint_t)*tmp))) {
*tmp = 0;
tmp--;
}
@@ -570,7 +570,6 @@ static void insert_error(icalcomponent *comp, const char *text,
snprintf(temp, 1024, "%s: %s", message, text);
}
- /* coverity[leaked_storage] */
icalcomponent_add_property(
comp,
icalproperty_vanew_xlicerror(temp, icalparameter_new_xlicerrortype(type), 0));
@@ -713,12 +712,6 @@ icalcomponent *icalparser_add_line(icalparser *parser, char *line)
comp_kind = icalenum_string_to_component_kind(str);
- if (comp_kind == ICAL_NO_COMPONENT) {
- c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
- insert_error(c, str, "Parse error in component name",
- ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
- }
-
c = icalcomponent_new(comp_kind);
if (c == 0) {
@@ -962,8 +955,6 @@ icalcomponent *icalparser_add_line(icalparser *parser, char *line)
name = 0;
}
name_heap = parser_get_param_name_heap(str, &pvalue_heap);
-
- name = name_heap;
pvalue = pvalue_heap;
}
param = icalparameter_new_from_value_string(kind, pvalue);
diff --git a/src/libical/icalproperty_cxx.cpp b/src/libical/icalproperty_cxx.cpp
index 95e59f26..ac22c9ae 100644
--- a/src/libical/icalproperty_cxx.cpp
+++ b/src/libical/icalproperty_cxx.cpp
@@ -27,7 +27,7 @@ ICalProperty::ICalProperty() : imp(icalproperty_new(ICAL_ANY_PROPERTY))
}
ICalProperty::ICalProperty(const ICalProperty &v) throw(icalerrorenum)
- : imp(icalproperty_new_clone(v.imp))
+ : imp(icalproperty_new_clone(v.imp))
{
if (imp == NULL) {
throw icalerrno;
@@ -68,18 +68,18 @@ ICalProperty::ICalProperty(icalproperty *v) : imp(v)
}
ICalProperty::ICalProperty(std::string str)
- : imp(icalproperty_new_from_string(str.c_str()))
+ : imp(icalproperty_new_from_string(str.c_str()))
{
}
ICalProperty::ICalProperty(icalproperty_kind kind)
- : imp(icalproperty_new(kind))
+ : imp(icalproperty_new(kind))
{
}
std::string ICalProperty::as_ical_string()
{
- return (std::string)icalproperty_as_ical_string(imp);
+ return static_cast<std::string>(icalproperty_as_ical_string(imp));
}
icalproperty_kind ICalProperty::isa()
@@ -97,9 +97,11 @@ int ICalProperty::operator==(ICalProperty &rhs)
icalparameter_xliccomparetype result;
ICalValue *thisPropValue = this->get_value();
ICalValue *rhsPropValue = rhs.get_value();
- result = icalvalue_compare((icalvalue *)*thisPropValue, (icalvalue *)*rhsPropValue);
+ result = icalvalue_compare(static_cast<icalvalue *>(*thisPropValue),
+ static_cast<icalvalue *>(*rhsPropValue));
delete thisPropValue;
- return (result == ICAL_XLICCOMPARETYPE_EQUAL);
+ delete rhsPropValue;
+ return (result == ICAL_XLICCOMPARETYPE_EQUAL) ? 1 : 0;
}
void ICalProperty::add_parameter(ICalParameter &parameter)
@@ -119,7 +121,7 @@ void ICalProperty::set_parameter_from_string(const std::string &name, const std:
std::string ICalProperty::get_parameter_as_string(const std::string &name)
{
- return (std::string)icalproperty_get_parameter_as_string(imp, name.c_str());
+ return static_cast<std::string>(icalproperty_get_parameter_as_string(imp, name.c_str()));
}
void ICalProperty::remove_parameter(const icalparameter_kind &kind)
@@ -148,7 +150,7 @@ ICalParameter *ICalProperty::get_next_parameter(const icalparameter_kind &kind)
/** Access the value of the property */
void ICalProperty::set_value(const ICalValue &val)
{
- icalproperty_set_value(imp, (ICalValue &)val);
+ icalproperty_set_value(imp, const_cast<ICalValue &>(val));
}
void ICalProperty::set_value_from_string(const std::string &val, const std::string &kind)
@@ -163,7 +165,7 @@ ICalValue *ICalProperty::get_value()
std::string ICalProperty::get_value_as_string()
{
- return (std::string)icalproperty_get_value_as_string(imp);
+ return static_cast<std::string>(icalproperty_get_value_as_string(imp));
}
/** Return the name of the property -- the type name converted to a
@@ -171,7 +173,7 @@ std::string ICalProperty::get_value_as_string()
*/
std::string ICalProperty::get_name() const
{
- return (std::string)icalproperty_get_property_name(imp);
+ return static_cast<std::string>(icalproperty_get_property_name(imp));
}
/* Deal with X properties */
@@ -182,7 +184,7 @@ void ICalProperty::set_x_name(ICalProperty &prop, const std::string &name)
std::string ICalProperty::get_x_name(ICalProperty &prop)
{
- return (std::string)icalproperty_get_x_name(prop);
+ return static_cast<std::string>(icalproperty_get_x_name(prop));
}
icalvalue_kind ICalProperty::value_to_value_kind(const icalparameter_value &val)
@@ -203,7 +205,7 @@ icalproperty_kind ICalProperty::value_kind_to_kind(const icalvalue_kind &kind)
std::string ICalProperty::kind_to_string(const icalproperty_kind &kind)
{
- return (std::string)icalproperty_kind_to_string(kind);
+ return static_cast<std::string>(icalproperty_kind_to_string(kind));
}
icalproperty_kind ICalProperty::string_to_kind(const std::string &str)
@@ -213,7 +215,7 @@ icalproperty_kind ICalProperty::string_to_kind(const std::string &str)
std::string ICalProperty::method_to_string(const icalproperty_method &method)
{
- return (std::string)icalproperty_method_to_string(method);
+ return static_cast<std::string>(icalproperty_method_to_string(method));
}
icalproperty_method ICalProperty::string_to_method(const std::string &str)
@@ -223,7 +225,7 @@ icalproperty_method ICalProperty::string_to_method(const std::string &str)
std::string ICalProperty::enum_to_string(const int &e)
{
- return (std::string)icalproperty_enum_to_string(e);
+ return static_cast<std::string>(icalproperty_enum_to_string(e));
}
int ICalProperty::string_to_enum(const std::string &str)
@@ -231,9 +233,9 @@ int ICalProperty::string_to_enum(const std::string &str)
return icalproperty_string_to_enum(str.c_str());
}
-std::string ICalProperty::status_to_string(const icalproperty_status &s)
+std::string ICalProperty::status_to_string(const icalproperty_status &status)
{
- return (std::string)icalproperty_status_to_string(s);
+ return static_cast<std::string>(icalproperty_status_to_string(status));
}
icalproperty_status ICalProperty::string_to_status(const std::string &str)
@@ -276,7 +278,7 @@ void ICalProperty::set_attendee(const std::string &val)
std::string ICalProperty::get_attendee() const
{
- return (std::string)icalproperty_get_attendee(imp);
+ return static_cast<std::string>(icalproperty_get_attendee(imp));
}
/* CALSCALE */
@@ -287,7 +289,7 @@ void ICalProperty::set_calscale(const std::string &val)
std::string ICalProperty::get_calscale() const
{
- return (std::string)icalproperty_get_calscale(imp);
+ return static_cast<std::string>(icalproperty_get_calscale(imp));
}
/* CATEGORIES */
@@ -298,7 +300,7 @@ void ICalProperty::set_categories(const std::string &val)
std::string ICalProperty::get_categories() const
{
- return (std::string)icalproperty_get_categories(imp);
+ return static_cast<std::string>(icalproperty_get_categories(imp));
}
/* CLASS */
@@ -309,7 +311,7 @@ void ICalProperty::set_class(const enum icalproperty_class &val)
enum icalproperty_class ICalProperty::get_class() const
{
- return (enum icalproperty_class)icalproperty_get_class(imp);
+ return static_cast<enum icalproperty_class>(icalproperty_get_class(imp));
}
/* COMMENT */
@@ -320,7 +322,7 @@ void ICalProperty::set_comment(const std::string &val)
std::string ICalProperty::get_comment() const
{
- return (std::string)icalproperty_get_comment(imp);
+ return static_cast<std::string>(icalproperty_get_comment(imp));
}
/* COMPLETED */
@@ -329,8 +331,7 @@ void ICalProperty::set_completed(const struct icaltimetype &val)
icalproperty_set_completed(imp, val);
}
-struct icaltimetype ICalProperty::get_completed() const
-{
+struct icaltimetype ICalProperty::get_completed() const {
return icalproperty_get_completed(imp);
}
@@ -342,7 +343,7 @@ void ICalProperty::set_contact(const std::string &val)
std::string ICalProperty::get_contact() const
{
- return (std::string)icalproperty_get_contact(imp);
+ return static_cast<std::string>(icalproperty_get_contact(imp));
}
/* CREATED */
@@ -351,8 +352,7 @@ void ICalProperty::set_created(const struct icaltimetype &val)
icalproperty_set_created(imp, val);
}
-struct icaltimetype ICalProperty::get_created() const
-{
+struct icaltimetype ICalProperty::get_created() const {
return icalproperty_get_created(imp);
}
@@ -364,7 +364,7 @@ void ICalProperty::set_description(const std::string &val)
std::string ICalProperty::get_description() const
{
- return (std::string)icalproperty_get_description(imp);
+ return static_cast<std::string>(icalproperty_get_description(imp));
}
/* DTEND */
@@ -373,8 +373,7 @@ void ICalProperty::set_dtend(const struct icaltimetype &val)
icalproperty_set_dtend(imp, val);
}
-struct icaltimetype ICalProperty::get_dtend() const
-{
+struct icaltimetype ICalProperty::get_dtend() const {
return icalproperty_get_dtend(imp);
}
@@ -384,8 +383,7 @@ void ICalProperty::set_dtstamp(const struct icaltimetype &val)
icalproperty_set_dtstamp(imp, val);
}
-struct icaltimetype ICalProperty::get_dtstamp() const
-{
+struct icaltimetype ICalProperty::get_dtstamp() const {
return icalproperty_get_dtstamp(imp);
}
@@ -395,8 +393,7 @@ void ICalProperty::set_dtstart(const struct icaltimetype &val)
icalproperty_set_dtstart(imp, val);
}
-struct icaltimetype ICalProperty::get_dtstart() const
-{
+struct icaltimetype ICalProperty::get_dtstart() const {
return icalproperty_get_dtstart(imp);
}
@@ -406,8 +403,7 @@ void ICalProperty::set_due(const struct icaltimetype &val)
icalproperty_set_due(imp, val);
}
-struct icaltimetype ICalProperty::get_due() const
-{
+struct icaltimetype ICalProperty::get_due() const {
return icalproperty_get_due(imp);
}
@@ -417,8 +413,7 @@ void ICalProperty::set_duration(const struct icaldurationtype &val)
icalproperty_set_duration(imp, val);
}
-struct icaldurationtype ICalProperty::get_duration() const
-{
+struct icaldurationtype ICalProperty::get_duration() const {
return icalproperty_get_duration(imp);
}
@@ -428,8 +423,7 @@ void ICalProperty::set_exdate(const struct icaltimetype &val)
icalproperty_set_exdate(imp, val);
}
-struct icaltimetype ICalProperty::get_exdate() const
-{
+struct icaltimetype ICalProperty::get_exdate() const {
return icalproperty_get_exdate(imp);
}
@@ -450,8 +444,7 @@ void ICalProperty::set_exrule(const struct icalrecurrencetype &val)
icalproperty_set_exrule(imp, val);
}
-struct icalrecurrencetype ICalProperty::get_exrule() const
-{
+struct icalrecurrencetype ICalProperty::get_exrule() const {
return icalproperty_get_exrule(imp);
}
@@ -461,8 +454,7 @@ void ICalProperty::set_freebusy(const struct icalperiodtype &val)
icalproperty_set_freebusy(imp, val);
}
-struct icalperiodtype ICalProperty::get_freebusy() const
-{
+struct icalperiodtype ICalProperty::get_freebusy() const {
return icalproperty_get_freebusy(imp);
}
@@ -472,8 +464,7 @@ void ICalProperty::set_geo(const struct icalgeotype &val)
icalproperty_set_geo(imp, val);
}
-struct icalgeotype ICalProperty::get_geo() const
-{
+struct icalgeotype ICalProperty::get_geo() const {
return icalproperty_get_geo(imp);
}
@@ -483,8 +474,7 @@ void ICalProperty::set_lastmodified(const struct icaltimetype &val)
icalproperty_set_lastmodified(imp, val);
}
-struct icaltimetype ICalProperty::get_lastmodified() const
-{
+struct icaltimetype ICalProperty::get_lastmodified() const {
return icalproperty_get_lastmodified(imp);
}
@@ -496,7 +486,7 @@ void ICalProperty::set_location(const std::string &val)
std::string ICalProperty::get_location() const
{
- return (std::string)icalproperty_get_location(imp);
+ return static_cast<std::string>(icalproperty_get_location(imp));
}
/* MAXRESULTS */
@@ -540,7 +530,7 @@ void ICalProperty::set_organizer(const std::string &val)
std::string ICalProperty::get_organizer() const
{
- return (std::string)icalproperty_get_organizer(imp);
+ return static_cast<std::string>(icalproperty_get_organizer(imp));
}
/* OWNER */
@@ -551,7 +541,7 @@ void ICalProperty::set_owner(const std::string &val)
std::string ICalProperty::get_owner() const
{
- return (std::string)icalproperty_get_owner(imp);
+ return static_cast<std::string>(icalproperty_get_owner(imp));
}
/* PERCENT-COMPLETE */
@@ -584,7 +574,7 @@ void ICalProperty::set_prodid(const std::string &val)
std::string ICalProperty::get_prodid() const
{
- return (std::string)icalproperty_get_prodid(imp);
+ return static_cast<std::string>(icalproperty_get_prodid(imp));
}
/* QUERY */
@@ -595,7 +585,7 @@ void ICalProperty::set_query(const std::string &val)
std::string ICalProperty::get_query() const
{
- return (std::string)icalproperty_get_query(imp);
+ return static_cast<std::string>(icalproperty_get_query(imp));
}
/* QUERYNAME */
@@ -606,7 +596,7 @@ void ICalProperty::set_queryname(const std::string &val)
std::string ICalProperty::get_queryname() const
{
- return (std::string)icalproperty_get_queryname(imp);
+ return static_cast<std::string>(icalproperty_get_queryname(imp));
}
/* RDATE */
@@ -615,8 +605,7 @@ void ICalProperty::set_rdate(const struct icaldatetimeperiodtype &val)
icalproperty_set_rdate(imp, val);
}
-struct icaldatetimeperiodtype ICalProperty::get_rdate() const
-{
+struct icaldatetimeperiodtype ICalProperty::get_rdate() const {
return icalproperty_get_rdate(imp);
}
@@ -626,8 +615,7 @@ void ICalProperty::set_recurrenceid(const struct icaltimetype &val)
icalproperty_set_recurrenceid(imp, val);
}
-struct icaltimetype ICalProperty::get_recurrenceid() const
-{
+struct icaltimetype ICalProperty::get_recurrenceid() const {
return icalproperty_get_recurrenceid(imp);
}
@@ -639,7 +627,7 @@ void ICalProperty::set_relatedto(const std::string &val)
std::string ICalProperty::get_relatedto() const
{
- return (std::string)icalproperty_get_relatedto(imp);
+ return static_cast<std::string>(icalproperty_get_relatedto(imp));
}
/* RELCALID */
@@ -650,7 +638,7 @@ void ICalProperty::set_relcalid(const std::string &val)
std::string ICalProperty::get_relcalid() const
{
- return (std::string)icalproperty_get_relcalid(imp);
+ return static_cast<std::string>(icalproperty_get_relcalid(imp));
}
/* REPEAT */
@@ -667,18 +655,15 @@ int ICalProperty::get_repeat() const
/* REQUEST-STATUS */
void ICalProperty::set_requeststatus(const std::string &val)
{
- icalreqstattype v;
-
- v = icalreqstattype_from_string(val.c_str());
+ icalreqstattype v = icalreqstattype_from_string(val.c_str());
icalproperty_set_requeststatus(imp, v);
}
std::string ICalProperty::get_requeststatus() const
{
- icalreqstattype v;
- v = icalproperty_get_requeststatus(imp);
- return (std::string)(icalreqstattype_as_string(v));
+ icalreqstattype v = icalproperty_get_requeststatus(imp);
+ return static_cast<std::string>(icalreqstattype_as_string(v));
}
/* RESOURCES */
@@ -689,7 +674,7 @@ void ICalProperty::set_resources(const std::string &val)
std::string ICalProperty::get_resources() const
{
- return (std::string)icalproperty_get_resources(imp);
+ return static_cast<std::string>(icalproperty_get_resources(imp));
}
/* RRULE */
@@ -698,8 +683,7 @@ void ICalProperty::set_rrule(const struct icalrecurrencetype &val)
icalproperty_set_rrule(imp, val);
}
-struct icalrecurrencetype ICalProperty::get_rrule() const
-{
+struct icalrecurrencetype ICalProperty::get_rrule() const {
return icalproperty_get_rrule(imp);
}
@@ -711,7 +695,7 @@ void ICalProperty::set_scope(const std::string &val)
std::string ICalProperty::get_scope() const
{
- return (std::string)icalproperty_get_scope(imp);
+ return static_cast<std::string>(icalproperty_get_scope(imp));
}
/* SEQUENCE */
@@ -744,7 +728,7 @@ void ICalProperty::set_summary(const std::string &val)
std::string ICalProperty::get_summary() const
{
- return (std::string)icalproperty_get_summary(imp);
+ return static_cast<std::string>(icalproperty_get_summary(imp));
}
/* TARGET */
@@ -755,7 +739,7 @@ void ICalProperty::set_target(const std::string &val)
std::string ICalProperty::get_target() const
{
- return (std::string)icalproperty_get_target(imp);
+ return static_cast<std::string>(icalproperty_get_target(imp));
}
/* TRANSP */
@@ -775,8 +759,7 @@ void ICalProperty::set_trigger(const struct icaltriggertype &val)
icalproperty_set_trigger(imp, val);
}
-struct icaltriggertype ICalProperty::get_trigger() const
-{
+struct icaltriggertype ICalProperty::get_trigger() const {
return icalproperty_get_trigger(imp);
}
@@ -788,7 +771,7 @@ void ICalProperty::set_tzid(const std::string &val)
std::string ICalProperty::get_tzid() const
{
- return (std::string)icalproperty_get_tzid(imp);
+ return static_cast<std::string>(icalproperty_get_tzid(imp));
}
/* TZNAME */
@@ -799,7 +782,7 @@ void ICalProperty::set_tzname(const std::string &val)
std::string ICalProperty::get_tzname() const
{
- return (std::string)icalproperty_get_tzname(imp);
+ return static_cast<std::string>(icalproperty_get_tzname(imp));
}
/* TZOFFSETFROM */
@@ -832,7 +815,7 @@ void ICalProperty::set_tzurl(const std::string &val)
std::string ICalProperty::get_tzurl() const
{
- return (std::string)icalproperty_get_tzurl(imp);
+ return static_cast<std::string>(icalproperty_get_tzurl(imp));
}
/* UID */
@@ -843,7 +826,7 @@ void ICalProperty::set_uid(const std::string &val)
std::string ICalProperty::get_uid() const
{
- return (std::string)icalproperty_get_uid(imp);
+ return static_cast<std::string>(icalproperty_get_uid(imp));
}
/* URL */
@@ -854,7 +837,7 @@ void ICalProperty::set_url(const std::string &val)
std::string ICalProperty::get_url() const
{
- return (std::string)icalproperty_get_url(imp);
+ return static_cast<std::string>(icalproperty_get_url(imp));
}
/* VERSION */
@@ -865,7 +848,7 @@ void ICalProperty::set_version(const std::string &val)
std::string ICalProperty::get_version() const
{
- return (std::string)icalproperty_get_version(imp);
+ return static_cast<std::string>(icalproperty_get_version(imp));
}
/* X */
@@ -876,7 +859,7 @@ void ICalProperty::set_x(const std::string &val)
std::string ICalProperty::get_x() const
{
- return (std::string)icalproperty_get_x(imp);
+ return static_cast<std::string>(icalproperty_get_x(imp));
}
/* X-LIC-CLUSTERCOUNT */
@@ -887,7 +870,7 @@ void ICalProperty::set_xlicclustercount(const std::string &val)
std::string ICalProperty::get_xlicclustercount() const
{
- return (std::string)icalproperty_get_xlicclustercount(imp);
+ return static_cast<std::string>(icalproperty_get_xlicclustercount(imp));
}
/* X-LIC-ERROR */
@@ -898,7 +881,7 @@ void ICalProperty::set_xlicerror(const std::string &val)
std::string ICalProperty::get_xlicerror() const
{
- return (std::string)icalproperty_get_xlicerror(imp);
+ return static_cast<std::string>(icalproperty_get_xlicerror(imp));
}
/* X-LIC-MIMECHARSET */
@@ -909,7 +892,7 @@ void ICalProperty::set_xlicmimecharset(const std::string &val)
std::string ICalProperty::get_xlicmimecharset() const
{
- return (std::string)icalproperty_get_xlicmimecharset(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimecharset(imp));
}
/* X-LIC-MIMECID */
@@ -920,7 +903,7 @@ void ICalProperty::set_xlicmimecid(const std::string &val)
std::string ICalProperty::get_xlicmimecid() const
{
- return (std::string)icalproperty_get_xlicmimecid(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimecid(imp));
}
/* X-LIC-MIMECONTENTTYPE */
@@ -931,7 +914,7 @@ void ICalProperty::set_xlicmimecontenttype(const std::string &val)
std::string ICalProperty::get_xlicmimecontenttype() const
{
- return (std::string)icalproperty_get_xlicmimecontenttype(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimecontenttype(imp));
}
/* X-LIC-MIMEENCODING */
@@ -942,7 +925,7 @@ void ICalProperty::set_xlicmimeencoding(const std::string &val)
std::string ICalProperty::get_xlicmimeencoding() const
{
- return (std::string)icalproperty_get_xlicmimeencoding(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimeencoding(imp));
}
/* X-LIC-MIMEFILENAME */
@@ -953,7 +936,7 @@ void ICalProperty::set_xlicmimefilename(const std::string &val)
std::string ICalProperty::get_xlicmimefilename() const
{
- return (std::string)icalproperty_get_xlicmimefilename(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimefilename(imp));
}
/* X-LIC-MIMEOPTINFO */
@@ -964,5 +947,5 @@ void ICalProperty::set_xlicmimeoptinfo(const std::string &val)
std::string ICalProperty::get_xlicmimeoptinfo() const
{
- return (std::string)icalproperty_get_xlicmimeoptinfo(imp);
+ return static_cast<std::string>(icalproperty_get_xlicmimeoptinfo(imp));
}
diff --git a/src/libical/icalproperty_cxx.h b/src/libical/icalproperty_cxx.h
index a01ea26e..af8d1dbc 100644
--- a/src/libical/icalproperty_cxx.h
+++ b/src/libical/icalproperty_cxx.h
@@ -34,352 +34,352 @@ extern "C"
namespace LibICal
{
- class ICalParameter;
- class ICalValue;
+class ICalParameter;
+class ICalValue;
- class LIBICAL_ICAL_EXPORT ICalProperty
+class LIBICAL_ICAL_EXPORT ICalProperty
+{
+public:
+ ICalProperty();
+ ICalProperty(const ICalProperty &) throw(icalerrorenum);
+ ICalProperty &operator=(const ICalProperty &) throw(icalerrorenum);
+ ~ICalProperty();
+
+ explicit ICalProperty(icalproperty *v);
+ explicit ICalProperty(std::string str);
+ explicit ICalProperty(icalproperty_kind kind);
+ ICalProperty(icalproperty_kind kind, std::string str);
+
+ operator icalproperty *()
{
- public:
- ICalProperty();
- ICalProperty(const ICalProperty &) throw(icalerrorenum);
- ICalProperty & operator=(const ICalProperty &) throw(icalerrorenum);
- ~ICalProperty();
-
- explicit ICalProperty(icalproperty *v);
- explicit ICalProperty(std::string str);
- explicit ICalProperty(icalproperty_kind kind);
- ICalProperty(icalproperty_kind kind, std::string str);
-
- operator icalproperty *()
- {
- return imp;
- }
- int operator==(ICalProperty & rhs);
-
- void detach();
-
- public:
- std::string as_ical_string();
- icalproperty_kind isa();
- int isa_property(void *property);
-
- void add_parameter(ICalParameter & parameter);
- void set_parameter(ICalParameter & parameter);
- void set_parameter_from_string(const std::string & name, const std::string & val);
- std::string get_parameter_as_string(const std::string & name);
- void remove_parameter(const icalparameter_kind & kind);
- int count_parameters();
+ return imp;
+ }
+ int operator==(ICalProperty &rhs);
+
+ void detach();
+
+public:
+ std::string as_ical_string();
+ icalproperty_kind isa();
+ int isa_property(void *property);
+
+ void add_parameter(ICalParameter &parameter);
+ void set_parameter(ICalParameter &parameter);
+ void set_parameter_from_string(const std::string &name, const std::string &val);
+ std::string get_parameter_as_string(const std::string &name);
+ void remove_parameter(const icalparameter_kind &kind);
+ int count_parameters();
/** Iterate through the parameters */
- ICalParameter *get_first_parameter(const icalparameter_kind & kind);
- ICalParameter *get_next_parameter(const icalparameter_kind & kind);
+ ICalParameter *get_first_parameter(const icalparameter_kind &kind);
+ ICalParameter *get_next_parameter(const icalparameter_kind &kind);
/** Access the value of the property */
- void set_value(const ICalValue & val);
- void set_value_from_string(const std::string & val, const std::string & kind);
+ void set_value(const ICalValue &val);
+ void set_value_from_string(const std::string &val, const std::string &kind);
- ICalValue *get_value();
- std::string get_value_as_string();
+ ICalValue *get_value();
+ std::string get_value_as_string();
/** Return the name of the property -- the type name converted
* to a string, or the value of get_x_name if the type is X
* property
*/
- std::string get_name() const;
+ std::string get_name() const;
- public:
- /* Deal with X properties */
- static void set_x_name(ICalProperty & prop, const std::string & name);
- static std::string get_x_name(ICalProperty & prop);
+public:
+ /* Deal with X properties */
+ static void set_x_name(ICalProperty &prop, const std::string &name);
+ static std::string get_x_name(ICalProperty &prop);
- static icalvalue_kind value_to_value_kind(const icalparameter_value & val);
+ static icalvalue_kind value_to_value_kind(const icalparameter_value &val);
- /* Convert kinds to string and get default value type */
- static icalvalue_kind kind_to_value_kind(const icalproperty_kind & kind);
- static icalproperty_kind value_kind_to_kind(const icalvalue_kind & kind);
- static std::string kind_to_string(const icalproperty_kind & kind);
- static icalproperty_kind string_to_kind(const std::string & str);
+ /* Convert kinds to string and get default value type */
+ static icalvalue_kind kind_to_value_kind(const icalproperty_kind &kind);
+ static icalproperty_kind value_kind_to_kind(const icalvalue_kind &kind);
+ static std::string kind_to_string(const icalproperty_kind &kind);
+ static icalproperty_kind string_to_kind(const std::string &str);
- static icalproperty_method string_to_method(const std::string & str);
- static std::string method_to_string(const icalproperty_method & method);
+ static icalproperty_method string_to_method(const std::string &str);
+ static std::string method_to_string(const icalproperty_method &method);
- static std::string enum_to_string(const int &e);
- static int string_to_enum(const std::string & str);
+ static std::string enum_to_string(const int &e);
+ static int string_to_enum(const std::string &str);
- static std::string status_to_string(const icalproperty_status & status);
- static icalproperty_status string_to_status(const std::string & str);
+ static std::string status_to_string(const icalproperty_status &status);
+ static icalproperty_status string_to_status(const std::string &str);
- static int enum_belongs_to_property(const icalproperty_kind & kind, const int &e);
+ static int enum_belongs_to_property(const icalproperty_kind &kind, const int &e);
- public:
- /* ACTION */
- void set_action(const enum icalproperty_action &v);
- enum icalproperty_action get_action();
+public:
+ /* ACTION */
+ void set_action(const enum icalproperty_action &val);
+ enum icalproperty_action get_action();
- /* ATTACH */
- void set_attach(icalattach *v);
- icalattach *get_attach() const;
+ /* ATTACH */
+ void set_attach(icalattach *val);
+ icalattach *get_attach() const;
- /* ATTENDEE */
- void set_attendee(const std::string & val);
- std::string get_attendee() const;
+ /* ATTENDEE */
+ void set_attendee(const std::string &val);
+ std::string get_attendee() const;
- /* CALSCALE */
- void set_calscale(const std::string & val);
- std::string get_calscale() const;
+ /* CALSCALE */
+ void set_calscale(const std::string &val);
+ std::string get_calscale() const;
- /* CATEGORIES */
- void set_categories(const std::string & val);
- std::string get_categories() const;
+ /* CATEGORIES */
+ void set_categories(const std::string &val);
+ std::string get_categories() const;
- /* CLASS */
- void set_class(const enum icalproperty_class &val);
- enum icalproperty_class get_class() const;
+ /* CLASS */
+ void set_class(const enum icalproperty_class &val);
+ enum icalproperty_class get_class() const;
- /* COMMENT */
- void set_comment(const std::string & val);
- std::string get_comment() const;
+ /* COMMENT */
+ void set_comment(const std::string &val);
+ std::string get_comment() const;
- /* COMPLETED */
- void set_completed(const struct icaltimetype &val);
- struct icaltimetype get_completed() const;
+ /* COMPLETED */
+ void set_completed(const struct icaltimetype &val);
+ struct icaltimetype get_completed() const;
- /* CONTACT */
- void set_contact(const std::string & val);
- std::string get_contact() const;
+ /* CONTACT */
+ void set_contact(const std::string &val);
+ std::string get_contact() const;
- /* CREATED */
- void set_created(const struct icaltimetype &val);
- struct icaltimetype get_created() const;
+ /* CREATED */
+ void set_created(const struct icaltimetype &val);
+ struct icaltimetype get_created() const;
- /* DESCRIPTION */
- void set_description(const std::string & val);
- std::string get_description() const;
+ /* DESCRIPTION */
+ void set_description(const std::string &val);
+ std::string get_description() const;
- /* DTEND */
- void set_dtend(const struct icaltimetype &val);
- struct icaltimetype get_dtend() const;
+ /* DTEND */
+ void set_dtend(const struct icaltimetype &val);
+ struct icaltimetype get_dtend() const;
- /* DTSTAMP */
- void set_dtstamp(const struct icaltimetype &val);
- struct icaltimetype get_dtstamp() const;
+ /* DTSTAMP */
+ void set_dtstamp(const struct icaltimetype &val);
+ struct icaltimetype get_dtstamp() const;
- /* DTSTART */
- void set_dtstart(const struct icaltimetype &val);
- struct icaltimetype get_dtstart() const;
+ /* DTSTART */
+ void set_dtstart(const struct icaltimetype &val);
+ struct icaltimetype get_dtstart() const;
- /* DUE */
- void set_due(const struct icaltimetype &val);
- struct icaltimetype get_due() const;
+ /* DUE */
+ void set_due(const struct icaltimetype &val);
+ struct icaltimetype get_due() const;
- /* DURATION */
- void set_duration(const struct icaldurationtype &val);
- struct icaldurationtype get_duration() const;
+ /* DURATION */
+ void set_duration(const struct icaldurationtype &val);
+ struct icaldurationtype get_duration() const;
- /* EXDATE */
- void set_exdate(const struct icaltimetype &val);
- struct icaltimetype get_exdate() const;
+ /* EXDATE */
+ void set_exdate(const struct icaltimetype &val);
+ struct icaltimetype get_exdate() const;
- /* EXPAND */
- void set_expand(const int &val);
- int get_expand() const;
+ /* EXPAND */
+ void set_expand(const int &val);
+ int get_expand() const;
- /* EXRULE */
- void set_exrule(const struct icalrecurrencetype &val);
- struct icalrecurrencetype get_exrule() const;
+ /* EXRULE */
+ void set_exrule(const struct icalrecurrencetype &val);
+ struct icalrecurrencetype get_exrule() const;
- /* FREEBUSY */
- void set_freebusy(const struct icalperiodtype &val);
- struct icalperiodtype get_freebusy() const;
+ /* FREEBUSY */
+ void set_freebusy(const struct icalperiodtype &val);
+ struct icalperiodtype get_freebusy() const;
- /* GEO */
- void set_geo(const struct icalgeotype &val);
- struct icalgeotype get_geo() const;
+ /* GEO */
+ void set_geo(const struct icalgeotype &val);
+ struct icalgeotype get_geo() const;
- /* GRANT */
- void set_grant(const std::string & val);
- std::string get_grant() const;
+ /* GRANT */
+ void set_grant(const std::string &val);
+ std::string get_grant() const;
- /* LAST-MODIFIED */
- void set_lastmodified(const struct icaltimetype &val);
- struct icaltimetype get_lastmodified() const;
+ /* LAST-MODIFIED */
+ void set_lastmodified(const struct icaltimetype &val);
+ struct icaltimetype get_lastmodified() const;
- /* LOCATION */
- void set_location(const std::string & val);
- std::string get_location() const;
+ /* LOCATION */
+ void set_location(const std::string &val);
+ std::string get_location() const;
- /* MAXRESULTS */
- void set_maxresults(const int &val);
- int get_maxresults() const;
+ /* MAXRESULTS */
+ void set_maxresults(const int &val);
+ int get_maxresults() const;
- /* MAXRESULTSSIZE */
- void set_maxresultsize(const int &val);
- int get_maxresultsize() const;
+ /* MAXRESULTSSIZE */
+ void set_maxresultsize(const int &val);
+ int get_maxresultsize() const;
- /* METHOD */
- void set_method(const enum icalproperty_method &val);
- enum icalproperty_method get_method() const;
+ /* METHOD */
+ void set_method(const enum icalproperty_method &val);
+ enum icalproperty_method get_method() const;
- /* OWNER */
- void set_owner(const std::string & val);
- std::string get_owner() const;
+ /* OWNER */
+ void set_owner(const std::string &val);
+ std::string get_owner() const;
- /* ORGANIZER */
- void set_organizer(const std::string & val);
- std::string get_organizer() const;
+ /* ORGANIZER */
+ void set_organizer(const std::string &val);
+ std::string get_organizer() const;
- /* PERCENT-COMPLETE */
- void set_percentcomplete(const int &val);
- int get_percentcomplete() const;
+ /* PERCENT-COMPLETE */
+ void set_percentcomplete(const int &val);
+ int get_percentcomplete() const;
- /* PRIORITY */
- void set_priority(const int &val);
- int get_priority() const;
+ /* PRIORITY */
+ void set_priority(const int &val);
+ int get_priority() const;
- /* PRODID */
- void set_prodid(const std::string & val);
- std::string get_prodid() const;
+ /* PRODID */
+ void set_prodid(const std::string &val);
+ std::string get_prodid() const;
- /* QUERY */
- void set_query(const std::string & val);
- std::string get_query() const;
+ /* QUERY */
+ void set_query(const std::string &val);
+ std::string get_query() const;
- /* QUERYNAME */
- void set_queryname(const std::string & val);
- std::string get_queryname() const;
+ /* QUERYNAME */
+ void set_queryname(const std::string &val);
+ std::string get_queryname() const;
- /* RDATE */
- void set_rdate(const struct icaldatetimeperiodtype &val);
- struct icaldatetimeperiodtype get_rdate() const;
+ /* RDATE */
+ void set_rdate(const struct icaldatetimeperiodtype &val);
+ struct icaldatetimeperiodtype get_rdate() const;
- /* RECURRENCE-ID */
- void set_recurrenceid(const struct icaltimetype &val);
- struct icaltimetype get_recurrenceid() const;
+ /* RECURRENCE-ID */
+ void set_recurrenceid(const struct icaltimetype &val);
+ struct icaltimetype get_recurrenceid() const;
- /* RELATED-TO */
- void set_relatedto(const std::string & val);
- std::string get_relatedto() const;
+ /* RELATED-TO */
+ void set_relatedto(const std::string &val);
+ std::string get_relatedto() const;
- /* RELCALID */
- void set_relcalid(const std::string & val);
- std::string get_relcalid() const;
+ /* RELCALID */
+ void set_relcalid(const std::string &val);
+ std::string get_relcalid() const;
- /* REPEAT */
- void set_repeat(const int &val);
- int get_repeat() const;
+ /* REPEAT */
+ void set_repeat(const int &val);
+ int get_repeat() const;
- /* REQUEST-STATUS */
- void set_requeststatus(const std::string & val);
- std::string get_requeststatus() const;
+ /* REQUEST-STATUS */
+ void set_requeststatus(const std::string &val);
+ std::string get_requeststatus() const;
- /* RESOURCES */
- void set_resources(const std::string & val);
- std::string get_resources() const;
+ /* RESOURCES */
+ void set_resources(const std::string &val);
+ std::string get_resources() const;
- /* RRULE */
- void set_rrule(const struct icalrecurrencetype &val);
- struct icalrecurrencetype get_rrule() const;
+ /* RRULE */
+ void set_rrule(const struct icalrecurrencetype &val);
+ struct icalrecurrencetype get_rrule() const;
- /* SCOPE */
- void set_scope(const std::string & val);
- std::string get_scope() const;
+ /* SCOPE */
+ void set_scope(const std::string &val);
+ std::string get_scope() const;
- /* SEQUENCE */
- void set_sequence(const int &val);
- int get_sequence() const;
+ /* SEQUENCE */
+ void set_sequence(const int &val);
+ int get_sequence() const;
- /* STATUS */
- void set_status(const enum icalproperty_status &val);
- enum icalproperty_status get_status() const;
+ /* STATUS */
+ void set_status(const enum icalproperty_status &val);
+ enum icalproperty_status get_status() const;
- /* SUMMARY */
- void set_summary(const std::string & val);
- std::string get_summary() const;
+ /* SUMMARY */
+ void set_summary(const std::string &val);
+ std::string get_summary() const;
- /* TARGET */
- void set_target(const std::string & val);
- std::string get_target() const;
+ /* TARGET */
+ void set_target(const std::string &val);
+ std::string get_target() const;
- /* TRANSP */
- void set_transp(const enum icalproperty_transp &val);
- enum icalproperty_transp get_transp() const;
+ /* TRANSP */
+ void set_transp(const enum icalproperty_transp &val);
+ enum icalproperty_transp get_transp() const;
- /* TRIGGER */
- void set_trigger(const struct icaltriggertype &val);
- struct icaltriggertype get_trigger() const;
+ /* TRIGGER */
+ void set_trigger(const struct icaltriggertype &val);
+ struct icaltriggertype get_trigger() const;
- /* TZID */
- void set_tzid(const std::string & val);
- std::string get_tzid() const;
+ /* TZID */
+ void set_tzid(const std::string &val);
+ std::string get_tzid() const;
- /* TZNAME */
- void set_tzname(const std::string & val);
- std::string get_tzname() const;
+ /* TZNAME */
+ void set_tzname(const std::string &val);
+ std::string get_tzname() const;
- /* TZOFFSETFROM */
- void set_tzoffsetfrom(const int &val);
- int get_tzoffsetfrom() const;
+ /* TZOFFSETFROM */
+ void set_tzoffsetfrom(const int &val);
+ int get_tzoffsetfrom() const;
- /* TZOFFSETTO */
- void set_tzoffsetto(const int &val);
- int get_tzoffsetto() const;
+ /* TZOFFSETTO */
+ void set_tzoffsetto(const int &val);
+ int get_tzoffsetto() const;
- /* TZURL */
- void set_tzurl(const std::string & val);
- std::string get_tzurl() const;
+ /* TZURL */
+ void set_tzurl(const std::string &val);
+ std::string get_tzurl() const;
- /* UID */
- void set_uid(const std::string & val);
- std::string get_uid() const;
+ /* UID */
+ void set_uid(const std::string &val);
+ std::string get_uid() const;
- /* URL */
- void set_url(const std::string & val);
- std::string get_url() const;
+ /* URL */
+ void set_url(const std::string &val);
+ std::string get_url() const;
- /* VERSION */
- void set_version(const std::string & val);
- std::string get_version() const;
+ /* VERSION */
+ void set_version(const std::string &val);
+ std::string get_version() const;
- /* X */
- void set_x(const std::string & val);
- std::string get_x() const;
+ /* X */
+ void set_x(const std::string &val);
+ std::string get_x() const;
- /* X-LIC-CLUSTERCOUNT */
- void set_xlicclustercount(const std::string & val);
- std::string get_xlicclustercount() const;
+ /* X-LIC-CLUSTERCOUNT */
+ void set_xlicclustercount(const std::string &val);
+ std::string get_xlicclustercount() const;
- /* X-LIC-ERROR */
- void set_xlicerror(const std::string & val);
- std::string get_xlicerror() const;
+ /* X-LIC-ERROR */
+ void set_xlicerror(const std::string &val);
+ std::string get_xlicerror() const;
- /* X-LIC-MIMECHARSET */
- void set_xlicmimecharset(const std::string & val);
- std::string get_xlicmimecharset() const;
+ /* X-LIC-MIMECHARSET */
+ void set_xlicmimecharset(const std::string &val);
+ std::string get_xlicmimecharset() const;
- /* X-LIC-MIMECID */
- void set_xlicmimecid(const std::string & val);
- std::string get_xlicmimecid() const;
+ /* X-LIC-MIMECID */
+ void set_xlicmimecid(const std::string &val);
+ std::string get_xlicmimecid() const;
- /* X-LIC-MIMECONTENTTYPE */
- void set_xlicmimecontenttype(const std::string & val);
- std::string get_xlicmimecontenttype() const;
+ /* X-LIC-MIMECONTENTTYPE */
+ void set_xlicmimecontenttype(const std::string &val);
+ std::string get_xlicmimecontenttype() const;
- /* X-LIC-MIMEENCODING */
- void set_xlicmimeencoding(const std::string & val);
- std::string get_xlicmimeencoding() const;
+ /* X-LIC-MIMEENCODING */
+ void set_xlicmimeencoding(const std::string &val);
+ std::string get_xlicmimeencoding() const;
- /* X-LIC-MIMEFILENAME */
- void set_xlicmimefilename(const std::string & val);
- std::string get_xlicmimefilename() const;
+ /* X-LIC-MIMEFILENAME */
+ void set_xlicmimefilename(const std::string &val);
+ std::string get_xlicmimefilename() const;
- /* X-LIC-MIMEOPTINFO */
- void set_xlicmimeoptinfo(const std::string & val);
- std::string get_xlicmimeoptinfo() const;
+ /* X-LIC-MIMEOPTINFO */
+ void set_xlicmimeoptinfo(const std::string &val);
+ std::string get_xlicmimeoptinfo() const;
- private:
- icalproperty *imp;
- /**< The actual C based icalproperty */
- };
+private:
+ icalproperty *imp;
+ /**< The actual C based icalproperty */
+};
} // namespace LibICal
diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c
index 4d65f639..fe17afb2 100644
--- a/src/libical/icalrecur.c
+++ b/src/libical/icalrecur.c
@@ -585,7 +585,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char *str)
if (parser.rt.freq == ICAL_NO_RECURRENCE) r = -1;
} else if (icalrecurrencetype_rscale_is_supported() &&
strcasecmp(name, "RSCALE") == 0) {
- parser.rt.rscale = icalmemory_tmp_copy(value);
+ parser.rt.rscale = icalmemory_strdup(value);
} else if (icalrecurrencetype_rscale_is_supported() &&
strcasecmp(name, "SKIP") == 0) {
parser.rt.skip = icalrecur_string_to_skip(value);
@@ -641,6 +641,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char *str)
if (r) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
+ free(parser.rt.rscale);
icalrecurrencetype_clear(&parser.rt);
break;
}
@@ -2896,6 +2897,7 @@ int icalrecur_expand_recurrence(char *rule,
}
icalrecur_iterator_free(ritr);
}
+ free(recur.rscale);
return 1;
}
diff --git a/src/libical/icalrestriction.c.in b/src/libical/icalrestriction.c.in
index e187b06a..a5c73f0c 100644
--- a/src/libical/icalrestriction.c.in
+++ b/src/libical/icalrestriction.c.in
@@ -301,6 +301,8 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo
const icalrestriction_property_record *prop_record;
const char *funcr = 0;
icalproperty *prop;
+ icalparameter *errParam = NULL;
+ icalproperty *errProp = NULL;
int count;
int compare;
@@ -338,13 +340,9 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo
"Failed iTIP restrictions for %s property. "
"Expected %s instances of the property and got %d",
icalenum_property_kind_to_string(kind), restr_string_map[restr], count);
-
- icalcomponent_add_property(
- comp,
- icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype
- (ICAL_XLICERRORTYPE_INVALIDITIP), 0));
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP);
+ errProp = icalproperty_vanew_xlicerror(temp, errParam, 0);
+ icalcomponent_add_property(comp, errProp);
}
prop = icalcomponent_get_first_property(comp, kind);
@@ -354,12 +352,15 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo
}
if (funcr != 0) {
- icalcomponent_add_property(
- comp,
- icalproperty_vanew_xlicerror(
- funcr,
- icalparameter_new_xlicerrortype
- (ICAL_XLICERRORTYPE_INVALIDITIP), 0));
+ if (errParam != NULL)
+ icalparameter_free(errParam);
+
+ if (errProp != NULL)
+ icalproperty_free(errProp);
+
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP);
+ errProp = icalproperty_vanew_xlicerror(funcr, errParam, 0);
+ icalcomponent_add_property(comp, errProp);
compare = 0;
}
diff --git a/src/libical/icaltime.c b/src/libical/icaltime.c
index ca647633..4077ce75 100644
--- a/src/libical/icaltime.c
+++ b/src/libical/icaltime.c
@@ -445,7 +445,7 @@ struct icaltimetype icaltime_from_string(const char *str)
tt.is_utc = 0;
tt.is_date = 0;
} else if ((size == 16) || (size == 20)) { /* UTC time, ends in 'Z' */
- if ((str[15] != 'Z') && (str[19] != 'Z'))
+ if ((str[size-1] != 'Z'))
goto FAIL;
tt.is_utc = 1;
diff --git a/src/libical/icaltimezone.c b/src/libical/icaltimezone.c
index 91f86d31..588158bf 100644
--- a/src/libical/icaltimezone.c
+++ b/src/libical/icaltimezone.c
@@ -222,8 +222,10 @@ static void icaltimezone_reset(icaltimezone *zone)
if (zone->component)
icalcomponent_free(zone->component);
- if (zone->changes)
+ if (zone->changes) {
icalarray_free(zone->changes);
+ zone->changes = NULL;
+ }
icaltimezone_init(zone);
}
@@ -474,8 +476,10 @@ static void icaltimezone_expand_changes(icaltimezone *zone, int end_year)
matter. */
icalarray_sort(changes, icaltimezone_compare_change_fn);
- if (zone->changes)
+ if (zone->changes) {
icalarray_free(zone->changes);
+ zone->changes = 0;
+ }
zone->changes = changes;
zone->end_year = end_year;
@@ -1531,7 +1535,8 @@ static int fetch_lat_long_from_string(const char *str,
}
len = (ptrdiff_t) (sptr - temp);
lat = (char *)malloc(len + 1);
- lat = strncpy(lat, temp, len);
+ memset(lat, '\0', len);
+ strncpy(lat, temp, len);
lat[len] = '\0';
while (*sptr != '\t') {
sptr++;
diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c
index 753295f3..a4773783 100644
--- a/src/libical/icaltz-util.c
+++ b/src/libical/icaltz-util.c
@@ -145,6 +145,7 @@ static int decode(const void *ptr)
const unsigned char *p = ptr;
int result = *p & (1 << (CHAR_BIT - 1)) ? ~0 : 0;
+ /* cppcheck-suppress shiftNegative */
result = (result << 8) | *p++;
result = (result << 8) | *p++;
result = (result << 8) | *p++;
diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c
index be7658f4..422d9bd4 100644
--- a/src/libical/icalvalue.c
+++ b/src/libical/icalvalue.c
@@ -128,14 +128,12 @@ icalvalue *icalvalue_new_clone(const icalvalue *old)
case ICAL_RECUR_VALUE:
{
if (old->data.v_recur != 0) {
- new->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
+ icalvalue_set_recur(new, *(old->data.v_recur));
if (new->data.v_recur == 0) {
icalvalue_free(new);
return 0;
}
-
- memcpy(new->data.v_recur, old->data.v_recur, sizeof(struct icalrecurrencetype));
}
break;
}
@@ -468,14 +466,14 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind,
}
case ICAL_BOOLEAN_VALUE:
{
- /* HACK */
- value = 0;
-
- if (error != 0) {
+ if (!strcmp(str, "TRUE")) value = icalvalue_new_boolean(1);
+ else if (!strcmp(str, "FALSE")) value = icalvalue_new_boolean(0);
+ else if (error != 0) {
char temp[TMP_BUF_SIZE];
- snprintf(temp, sizeof(temp), "%s Values are not implemented",
- icalvalue_kind_to_string(kind));
+ snprintf(temp, sizeof(temp),
+ "Could not parse %s as a %s property",
+ str, icalvalue_kind_to_string(kind));
*error = icalproperty_vanew_xlicerror(
temp,
icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR),
@@ -608,14 +606,14 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind,
geo_parsing_error:
if (error != 0) {
char temp[TMP_BUF_SIZE];
+ icalparameter *errParam;
snprintf(temp, sizeof(temp),
"Could not parse %s as a %s property",
str, icalvalue_kind_to_string(kind));
- *error = icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR),
- 0);
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR);
+ *error = icalproperty_vanew_xlicerror(temp, errParam, 0);
+ icalparameter_free(errParam);
}
}
break;
@@ -721,14 +719,15 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind,
default:
{
char temp[TMP_BUF_SIZE];
+ icalparameter *errParam;
+
if (error != 0) {
snprintf(temp, TMP_BUF_SIZE, "Unknown type for \'%s\'", str);
- *error = icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR),
- 0);
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR);
+ *error = icalproperty_vanew_xlicerror(temp, errParam, 0);
+ icalparameter_free(errParam);
}
snprintf(temp, TMP_BUF_SIZE,
@@ -741,13 +740,13 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind,
if (error != 0 && *error == 0 && value == 0) {
char temp[TMP_BUF_SIZE];
+ icalparameter *errParam;
snprintf(temp, TMP_BUF_SIZE, "Failed to parse value: \'%s\'", str);
- *error = icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR),
- 0);
+ errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR);
+ *error = icalproperty_vanew_xlicerror(temp, errParam, 0);
+ icalparameter_free(errParam);
}
return value;
@@ -795,6 +794,7 @@ void icalvalue_free(icalvalue *v)
case ICAL_RECUR_VALUE:
{
if (v->data.v_recur != 0) {
+ free(v->data.v_recur->rscale);
free((void *)v->data.v_recur);
v->data.v_recur = 0;
}
@@ -836,6 +836,21 @@ static char *icalvalue_binary_as_ical_string_r(const icalvalue *value)
return str;
}
+static char *icalvalue_boolean_as_ical_string_r(const icalvalue *value)
+{
+ int data;
+ char *str;
+
+ icalerror_check_arg_rz((value != 0), "value");
+ str = (char *)icalmemory_new_buffer(6);
+
+ data = icalvalue_get_integer(value);
+
+ strcpy(str, data ? "TRUE" : "FALSE");
+
+ return str;
+}
+
#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign */
static char *icalvalue_int_as_ical_string_r(const icalvalue *value)
@@ -1147,6 +1162,8 @@ char *icalvalue_as_ical_string_r(const icalvalue *value)
return icalvalue_binary_as_ical_string_r(value);
case ICAL_BOOLEAN_VALUE:
+ return icalvalue_boolean_as_ical_string_r(value);
+
case ICAL_INTEGER_VALUE:
return icalvalue_int_as_ical_string_r(value);
diff --git a/src/libical/icalvalue.h b/src/libical/icalvalue.h
index c99b1eff..2742ae89 100644
--- a/src/libical/icalvalue.h
+++ b/src/libical/icalvalue.h
@@ -23,6 +23,9 @@
#include "libical_ical_export.h"
#include "icalvalueimpl.h"
+#define ICAL_BOOLEAN_TRUE 1
+#define ICAL_BOOLEAN_FALSE 0
+
LIBICAL_ICAL_EXPORT icalvalue *icalvalue_new(icalvalue_kind kind);
LIBICAL_ICAL_EXPORT icalvalue *icalvalue_new_clone(const icalvalue *value);
diff --git a/src/libical/icalvalue_cxx.cpp b/src/libical/icalvalue_cxx.cpp
index 734199e3..92dd2809 100644
--- a/src/libical/icalvalue_cxx.cpp
+++ b/src/libical/icalvalue_cxx.cpp
@@ -27,7 +27,7 @@ ICalValue::ICalValue() throw(icalerrorenum) : imp(icalvalue_new(ICAL_ANY_VALUE))
}
ICalValue::ICalValue(const ICalValue &v) throw (icalerrorenum)
- : imp(icalvalue_new_clone(v.imp))
+ : imp(icalvalue_new_clone(v.imp))
{
if (imp == NULL) {
throw icalerrno;
@@ -68,7 +68,7 @@ ICalValue::ICalValue(icalvalue *v) throw(icalerrorenum) : imp(v)
}
ICalValue::ICalValue(const icalvalue_kind &kind) throw(icalerrorenum)
- : imp(icalvalue_new(kind))
+ : imp(icalvalue_new(kind))
{
if (imp == NULL) {
throw icalerrno;
@@ -76,7 +76,7 @@ ICalValue::ICalValue(const icalvalue_kind &kind) throw(icalerrorenum)
}
ICalValue::ICalValue(const icalvalue_kind &kind, const std::string &str) throw(icalerrorenum)
- : imp(icalvalue_new_from_string(kind, str.c_str()))
+ : imp(icalvalue_new_from_string(kind, str.c_str()))
{
if (imp == NULL) {
throw icalerrno;
@@ -85,7 +85,7 @@ ICalValue::ICalValue(const icalvalue_kind &kind, const std::string &str) throw(i
std::string ICalValue::as_ical_string()
{
- return (std::string)icalvalue_as_ical_string(imp);
+ return static_cast<std::string>(icalvalue_as_ical_string(imp));
}
bool ICalValue::is_valid()
@@ -93,7 +93,7 @@ bool ICalValue::is_valid()
if (imp == NULL) {
return false;
}
- return (icalvalue_is_valid(imp) ? true : false);
+ return (icalvalue_is_valid(imp) != 0);
}
icalvalue_kind ICalValue::isa()
@@ -150,7 +150,7 @@ icalvalue_kind ICalValue::string_to_kind(const std::string &str)
std::string ICalValue::kind_to_string(const icalvalue_kind &kind)
{
- return (std::string)icalvalue_kind_to_string(kind);
+ return static_cast<std::string>(icalvalue_kind_to_string(kind));
}
/* BOOLEAN */
@@ -189,7 +189,7 @@ void ICalValue::set_method(const enum icalproperty_method &v)
/* CAL-ADDRESS */
std::string ICalValue::get_caladdress() const
{
- return (std::string)icalvalue_get_caladdress(imp);
+ return static_cast<std::string>(icalvalue_get_caladdress(imp));
}
void ICalValue::set_caladdress(const std::string &v)
@@ -198,8 +198,7 @@ void ICalValue::set_caladdress(const std::string &v)
}
/* PERIOD */
-struct icalperiodtype ICalValue::get_period() const
-{
+struct icalperiodtype ICalValue::get_period() const {
return icalvalue_get_period(imp);
}
@@ -222,7 +221,7 @@ void ICalValue::set_status(const enum icalproperty_status &v)
/* BINARY */
std::string ICalValue::get_binary() const
{
- return (std::string)icalvalue_get_binary(imp);
+ return static_cast<std::string>(icalvalue_get_binary(imp));
}
void ICalValue::set_binary(const std::string &v)
@@ -233,7 +232,7 @@ void ICalValue::set_binary(const std::string &v)
/* TEXT */
std::string ICalValue::get_text() const
{
- return (std::string)icalvalue_get_text(imp);
+ return static_cast<std::string>(icalvalue_get_text(imp));
}
void ICalValue::set_text(const std::string &v)
@@ -242,8 +241,7 @@ void ICalValue::set_text(const std::string &v)
}
/* DURATION */
-struct icaldurationtype ICalValue::get_duration() const
-{
+struct icaldurationtype ICalValue::get_duration() const {
return icalvalue_get_duration(imp);
}
@@ -266,7 +264,7 @@ void ICalValue::set_integer(const int &v)
/* URI */
std::string ICalValue::get_uri() const
{
- return (std::string)icalvalue_get_uri(imp);
+ return static_cast<std::string>(icalvalue_get_uri(imp));
}
void ICalValue::set_uri(const std::string &v)
@@ -310,7 +308,7 @@ void ICalValue::set_float(const float &v)
/* QUERY */
std::string ICalValue::get_query() const
{
- return (std::string)icalvalue_get_query(imp);
+ return static_cast<std::string>(icalvalue_get_query(imp));
}
void ICalValue::set_query(const std::string &v)
@@ -321,7 +319,7 @@ void ICalValue::set_query(const std::string &v)
/* STRING */
std::string ICalValue::get_string() const
{
- return (std::string)icalvalue_get_string(imp);
+ return static_cast<std::string>(icalvalue_get_string(imp));
}
void ICalValue::set_string(const std::string &v)
@@ -341,8 +339,7 @@ void ICalValue::set_transp(const enum icalproperty_transp &v)
}
/* DATE-TIME */
-struct icaltimetype ICalValue::get_datetime() const
-{
+struct icaltimetype ICalValue::get_datetime() const {
return icalvalue_get_datetime(imp);
}
@@ -352,8 +349,7 @@ void ICalValue::set_datetime(const struct icaltimetype &v)
}
/* GEO */
-struct icalgeotype ICalValue::get_geo() const
-{
+struct icalgeotype ICalValue::get_geo() const {
return icalvalue_get_geo(imp);
}
@@ -363,8 +359,7 @@ void ICalValue::set_geo(const struct icalgeotype &v)
}
/* DATE */
-struct icaltimetype ICalValue::get_date() const
-{
+struct icaltimetype ICalValue::get_date() const {
return icalvalue_get_date(imp);
}
diff --git a/src/libical/icalvalue_cxx.h b/src/libical/icalvalue_cxx.h
index aad2c072..aa8a21ff 100644
--- a/src/libical/icalvalue_cxx.h
+++ b/src/libical/icalvalue_cxx.h
@@ -32,138 +32,138 @@ extern "C"
namespace LibICal
{
- class LIBICAL_ICAL_EXPORT ICalValue
- {
- public:
- ICalValue() throw(icalerrorenum);
- ICalValue(const ICalValue &) throw(icalerrorenum);
- ICalValue & operator=(const ICalValue &) throw(icalerrorenum);
- ~ICalValue();
+class LIBICAL_ICAL_EXPORT ICalValue
+{
+public:
+ ICalValue() throw(icalerrorenum);
+ ICalValue(const ICalValue &) throw(icalerrorenum);
+ ICalValue &operator=(const ICalValue &) throw(icalerrorenum);
+ ~ICalValue();
- explicit ICalValue(icalvalue *) throw(icalerrorenum);
- explicit ICalValue(const icalvalue_kind & kind) throw(icalerrorenum);
- ICalValue(const icalvalue_kind & kind, const std::string & str) throw(icalerrorenum);
+ explicit ICalValue(icalvalue *) throw(icalerrorenum);
+ explicit ICalValue(const icalvalue_kind &kind) throw(icalerrorenum);
+ ICalValue(const icalvalue_kind &kind, const std::string &str) throw(icalerrorenum);
- operator icalvalue *()
- {
- return imp;
- }
+ operator icalvalue *()
+ {
+ return imp;
+ }
- void detach();
+ void detach();
- public:
- std::string as_ical_string();
- bool is_valid();
- icalvalue_kind isa();
- int isa_value(void *);
+public:
+ std::string as_ical_string();
+ bool is_valid();
+ icalvalue_kind isa();
+ int isa_value(void *);
- /* Special, non autogenerated value accessors */
- void set_recur(const struct icalrecurrencetype &v);
- struct icalrecurrencetype get_recur();
+ /* Special, non autogenerated value accessors */
+ void set_recur(const struct icalrecurrencetype &v);
+ struct icalrecurrencetype get_recur();
- void set_trigger(const struct icaltriggertype &v);
- struct icaltriggertype get_trigger();
+ void set_trigger(const struct icaltriggertype &v);
+ struct icaltriggertype get_trigger();
- void set_datetimeperiod(const struct icaldatetimeperiodtype &v);
- struct icaldatetimeperiodtype get_datetimeperiod();
+ void set_datetimeperiod(const struct icaldatetimeperiodtype &v);
+ struct icaldatetimeperiodtype get_datetimeperiod();
- public:
- static icalparameter_xliccomparetype compare(ICalValue & a, ICalValue & b);
+public:
+ static icalparameter_xliccomparetype compare(ICalValue &a, ICalValue &b);
- /* Convert enumerations */
- static icalvalue_kind string_to_kind(const std::string & str);
- std::string kind_to_string(const icalvalue_kind & kind);
+ /* Convert enumerations */
+ static icalvalue_kind string_to_kind(const std::string &str);
+ std::string kind_to_string(const icalvalue_kind &kind);
- public:
- /* BOOLEAN */
- int get_boolean() const;
- void set_boolean(const int &v);
+public:
+ /* BOOLEAN */
+ int get_boolean() const;
+ void set_boolean(const int &v);
- /* UTC-OFFSET */
- int get_utcoffset() const;
- void set_utcoffset(const int &v);
+ /* UTC-OFFSET */
+ int get_utcoffset() const;
+ void set_utcoffset(const int &v);
- /* METHOD */
- enum icalproperty_method get_method() const;
- void set_method(const enum icalproperty_method &v);
+ /* METHOD */
+ enum icalproperty_method get_method() const;
+ void set_method(const enum icalproperty_method &v);
- /* CAL-ADDRESS */
- std::string get_caladdress() const;
- void set_caladdress(const std::string & v);
+ /* CAL-ADDRESS */
+ std::string get_caladdress() const;
+ void set_caladdress(const std::string &v);
- /* PERIOD */
- struct icalperiodtype get_period() const;
- void set_period(const struct icalperiodtype &v);
+ /* PERIOD */
+ struct icalperiodtype get_period() const;
+ void set_period(const struct icalperiodtype &v);
- /* STATUS */
- enum icalproperty_status get_status() const;
- void set_status(const enum icalproperty_status &v);
+ /* STATUS */
+ enum icalproperty_status get_status() const;
+ void set_status(const enum icalproperty_status &v);
- /* BINARY */
- std::string get_binary() const;
- void set_binary(const std::string & v);
+ /* BINARY */
+ std::string get_binary() const;
+ void set_binary(const std::string &v);
- /* TEXT */
- std::string get_text() const;
- void set_text(const std::string & v);
+ /* TEXT */
+ std::string get_text() const;
+ void set_text(const std::string &v);
- /* DURATION */
- struct icaldurationtype get_duration() const;
- void set_duration(const struct icaldurationtype &v);
+ /* DURATION */
+ struct icaldurationtype get_duration() const;
+ void set_duration(const struct icaldurationtype &v);
- /* INTEGER */
- int get_integer() const;
- void set_integer(const int &v);
+ /* INTEGER */
+ int get_integer() const;
+ void set_integer(const int &v);
- /* URI */
- std::string get_uri() const;
- void set_uri(const std::string & v);
+ /* URI */
+ std::string get_uri() const;
+ void set_uri(const std::string &v);
- /* ATTACH */
- icalattach *get_attach();
- void set_attach(icalattach *v);
+ /* ATTACH */
+ icalattach *get_attach();
+ void set_attach(icalattach *v);
- /* CLASS */
- enum icalproperty_class get_class() const;
- void set_class(const enum icalproperty_class &v);
+ /* CLASS */
+ enum icalproperty_class get_class() const;
+ void set_class(const enum icalproperty_class &v);
- /* FLOAT */
- float get_float() const;
- void set_float(const float &v);
+ /* FLOAT */
+ float get_float() const;
+ void set_float(const float &v);
- /* QUERY */
- std::string get_query() const;
- void set_query(const std::string & v);
+ /* QUERY */
+ std::string get_query() const;
+ void set_query(const std::string &v);
- /* STRING */
- std::string get_string() const;
- void set_string(const std::string & v);
+ /* STRING */
+ std::string get_string() const;
+ void set_string(const std::string &v);
- /* TRANSP */
- enum icalproperty_transp get_transp() const;
- void set_transp(const enum icalproperty_transp &v);
+ /* TRANSP */
+ enum icalproperty_transp get_transp() const;
+ void set_transp(const enum icalproperty_transp &v);
- /* DATE-TIME */
- struct icaltimetype get_datetime() const;
- void set_datetime(const struct icaltimetype &v);
+ /* DATE-TIME */
+ struct icaltimetype get_datetime() const;
+ void set_datetime(const struct icaltimetype &v);
- /* GEO */
- struct icalgeotype get_geo() const;
- void set_geo(const struct icalgeotype &v);
+ /* GEO */
+ struct icalgeotype get_geo() const;
+ void set_geo(const struct icalgeotype &v);
- /* DATE */
- struct icaltimetype get_date() const;
- void set_date(const struct icaltimetype &v);
+ /* DATE */
+ struct icaltimetype get_date() const;
+ void set_date(const struct icaltimetype &v);
- /* ACTION */
- enum icalproperty_action get_action() const;
- void set_action(const enum icalproperty_action &v);
+ /* ACTION */
+ enum icalproperty_action get_action() const;
+ void set_action(const enum icalproperty_action &v);
- private:
- icalvalue *imp;
- };
+private:
+ icalvalue *imp;
+};
-} // namespace LibICal
+} // namespace LibICal
typedef ICPointerHolder < LibICal::ICalValue > ICalValueTmpPtr;
diff --git a/src/libical/icptrholder_cxx.h b/src/libical/icptrholder_cxx.h
index e3dd3f98..dfd7bd57 100644
--- a/src/libical/icptrholder_cxx.h
+++ b/src/libical/icptrholder_cxx.h
@@ -44,21 +44,22 @@
#include <cassert>
-template < class T > class ICPointerHolder {
- public:
+template < class T > class ICPointerHolder
+{
+public:
ICPointerHolder()
- : ptr(0)
+ : ptr(0)
{
}
ICPointerHolder(T *p)
- : ptr(p)
+ : ptr(p)
{
}
// copy constructor to support assignment
ICPointerHolder(const ICPointerHolder &ip)
- : ptr(ip.ptr)
+ : ptr(ip.ptr)
{
// We need to transfer ownership of ptr to this object by setting
// ip's ptr to null. Otherwise, ptr will de deleted twice.
@@ -73,7 +74,7 @@ template < class T > class ICPointerHolder {
release();
}
- ICPointerHolder & operator=(T *p)
+ ICPointerHolder &operator=(T *p)
{
this->release();
ptr = p;
@@ -88,12 +89,12 @@ template < class T > class ICPointerHolder {
return *this;
}
- int operator!=(T *p)
+ bool operator!=(T *p)
{
return (ptr != p);
}
- int operator==(T *p)
+ bool operator==(T *p)
{
return (ptr == p);
}
@@ -115,7 +116,7 @@ template < class T > class ICPointerHolder {
return *ptr;
}
- private:
+private:
void release()
{
if (ptr != 0) {
diff --git a/src/libical/vcomponent_cxx.cpp b/src/libical/vcomponent_cxx.cpp
index aef9caa3..e4e78691 100644
--- a/src/libical/vcomponent_cxx.cpp
+++ b/src/libical/vcomponent_cxx.cpp
@@ -38,9 +38,9 @@ VComponent::VComponent() throw(icalerrorenum) : imp(icalcomponent_new(ICAL_ANY_C
}
VComponent::VComponent(const VComponent &v) throw(icalerrorenum)
- : imp(icalcomponent_new_clone(v.imp))
+ : imp(icalcomponent_new_clone(v.imp))
{
- if (!imp) {
+ if (imp == NULL) {
throw icalerrno;
}
}
@@ -54,7 +54,7 @@ VComponent &VComponent::operator=(const VComponent &v) throw(icalerrorenum)
if (imp != NULL) {
icalcomponent_free(imp);
imp = icalcomponent_new_clone(v.imp);
- if (!imp) {
+ if (imp == NULL) {
throw icalerrno;
}
}
@@ -69,7 +69,7 @@ void VComponent::detach()
VComponent::~VComponent()
{
- if (imp) {
+ if (imp != NULL) {
icalcomponent_free(imp);
}
}
@@ -85,7 +85,7 @@ char *VComponent::quote_ical_string(char *str)
size_t buf_sz;
buf_sz = strlen(str) * 2; // assume worse case scenarios.
// otherwise, we have to parse the string and count \ */
- char *out = (char *)icalmemory_new_buffer(buf_sz); /* memory is from the ring buffer */
+ char *out = static_cast<char *>(icalmemory_new_buffer(buf_sz)); /* memory from the ring buf */
char *pout;
if (out == 0) {
@@ -116,9 +116,9 @@ char *VComponent::quote_ical_string(char *str)
*
*/
VComponent::VComponent(const std::string &str) throw (icalerrorenum)
- : imp(icalcomponent_new_from_string(str.c_str()))
+ : imp(icalcomponent_new_from_string(str.c_str()))
{
- if (!imp) {
+ if (imp == NULL) {
if (! icalerrno) {
icalerrno = ICAL_BADARG_ERROR;
}
@@ -127,9 +127,9 @@ VComponent::VComponent(const std::string &str) throw (icalerrorenum)
}
VComponent::VComponent(const icalcomponent_kind &kind) throw(icalerrorenum)
- : imp(icalcomponent_new(kind))
+ : imp(icalcomponent_new(kind))
{
- if (!imp) {
+ if (imp == NULL) {
throw icalerrno;
}
}
@@ -138,7 +138,7 @@ std::string VComponent::as_ical_string() throw(icalerrorenum)
{
char *str = icalcomponent_as_ical_string(imp);
- if (!str) {
+ if (str == NULL) {
throw icalerrno;
}
@@ -150,7 +150,7 @@ bool VComponent::is_valid()
if (imp == NULL) {
return false;
}
- return (icalcomponent_is_valid(imp) ? true : false);
+ return (icalcomponent_is_valid(imp) != 0);
}
icalcomponent_kind VComponent::isa()
@@ -320,17 +320,17 @@ icalcompiter VComponent::end_component(const icalcomponent_kind &kind)
VComponent *VComponent::next(icalcompiter *i)
{
- return (VComponent *)icalcompiter_next(i);
+ return reinterpret_cast<VComponent *>(icalcompiter_next(i));
}
VComponent *VComponent::prev(icalcompiter *i)
{
- return (VComponent *)icalcompiter_prior(i);
+ return reinterpret_cast<VComponent *>(icalcompiter_prior(i));
}
VComponent *VComponent::current(icalcompiter *i)
{
- return (VComponent *)icalcompiter_deref(i);
+ return reinterpret_cast<VComponent *>(icalcompiter_deref(i));
}
/* Working with embedded error properties */
@@ -359,11 +359,10 @@ icalcomponent_kind VComponent::string_to_kind(const std::string &str)
std::string VComponent::kind_to_string(const icalcomponent_kind &kind)
{
- return (std::string)icalcomponent_kind_to_string(kind);
+ return static_cast<std::string>(icalcomponent_kind_to_string(kind));
}
-struct icaltimetype VComponent::get_dtstart() const
-{
+struct icaltimetype VComponent::get_dtstart() const {
return icalcomponent_get_dtstart(imp);
}
@@ -382,8 +381,7 @@ void VComponent::set_dtstart(const struct icaltimetype &v)
routine will create the apcompriate comperty.
*/
-struct icaltimetype VComponent::get_dtend() const
-{
+struct icaltimetype VComponent::get_dtend() const {
return icalcomponent_get_dtend(imp);
}
@@ -392,8 +390,7 @@ void VComponent::set_dtend(const struct icaltimetype &v)
icalcomponent_set_dtend(imp, v);
}
-struct icaltimetype VComponent::get_due() const
-{
+struct icaltimetype VComponent::get_due() const {
return icalcomponent_get_due(imp);
}
@@ -402,8 +399,7 @@ void VComponent::set_due(const struct icaltimetype &v)
icalcomponent_set_due(imp, v);
}
-struct icaldurationtype VComponent::get_duration() const
-{
+struct icaldurationtype VComponent::get_duration() const {
return icalcomponent_get_duration(imp);
}
@@ -422,8 +418,7 @@ void VComponent::set_method(const icalproperty_method &method)
icalcomponent_set_method(imp, method);
}
-struct icaltimetype VComponent::get_dtstamp() const
-{
+struct icaltimetype VComponent::get_dtstamp() const {
return icalcomponent_get_dtstamp(imp);
}
@@ -434,7 +429,7 @@ void VComponent::set_dtstamp(const struct icaltimetype &v)
std::string VComponent::get_summary() const
{
- return (std::string)icalcomponent_get_summary(imp);
+ return static_cast<std::string>(icalcomponent_get_summary(imp));
}
void VComponent::set_summary(const std::string &v)
@@ -444,7 +439,7 @@ void VComponent::set_summary(const std::string &v)
std::string VComponent::get_location() const
{
- return (std::string)icalcomponent_get_location(imp);
+ return static_cast<std::string>(icalcomponent_get_location(imp));
}
void VComponent::set_location(const std::string &v)
@@ -454,7 +449,7 @@ void VComponent::set_location(const std::string &v)
std::string VComponent::get_description() const
{
- return (std::string)icalcomponent_get_description(imp);
+ return static_cast<std::string>(icalcomponent_get_description(imp));
}
void VComponent::set_description(const std::string &v)
@@ -464,7 +459,7 @@ void VComponent::set_description(const std::string &v)
std::string VComponent::get_comment() const
{
- return (std::string)icalcomponent_get_comment(imp);
+ return static_cast<std::string>(icalcomponent_get_comment(imp));
}
void VComponent::set_comment(const std::string &v)
@@ -474,7 +469,7 @@ void VComponent::set_comment(const std::string &v)
std::string VComponent::get_uid() const
{
- return (std::string)icalcomponent_get_uid(imp);
+ return static_cast<std::string>(icalcomponent_get_uid(imp));
}
void VComponent::set_uid(const std::string &v)
@@ -484,7 +479,7 @@ void VComponent::set_uid(const std::string &v)
std::string VComponent::get_relcalid() const
{
- return (std::string)icalcomponent_get_relcalid(imp);
+ return static_cast<std::string>(icalcomponent_get_relcalid(imp));
}
void VComponent::set_relcalid(const std::string &v)
@@ -492,8 +487,7 @@ void VComponent::set_relcalid(const std::string &v)
icalcomponent_set_relcalid(imp, v.c_str());
}
-struct icaltimetype VComponent::get_recurrenceid() const
-{
+struct icaltimetype VComponent::get_recurrenceid() const {
return icalcomponent_get_recurrenceid(imp);
}
@@ -504,7 +498,7 @@ void VComponent::set_recurrenceid(const struct icaltimetype &v)
int VComponent::get_sequence() const
{
- return (int)icalcomponent_get_sequence(imp);
+ return icalcomponent_get_sequence(imp);
}
void VComponent::set_sequence(const int &v)
@@ -514,7 +508,7 @@ void VComponent::set_sequence(const int &v)
int VComponent::get_status() const
{
- return (int)icalcomponent_get_status(imp);
+ return icalcomponent_get_status(imp);
}
void VComponent::set_status(const enum icalproperty_status &v)
@@ -525,7 +519,7 @@ void VComponent::set_status(const enum icalproperty_status &v)
/* For VCOMPONENT: Return a reference to the first VEVENT, VTODO, or VJOURNAL */
VComponent *VComponent::get_first_real_component()
{
- return (VComponent *)icalcomponent_get_first_real_component(imp);
+ return reinterpret_cast<VComponent *>(icalcomponent_get_first_real_component(imp));
}
/* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
@@ -562,7 +556,8 @@ bool VComponent::remove(VComponent &fromVC, bool ignoreValue)
/* properties first */
ICalPropertyTmpPtr propToBeRemoved;
- for (propToBeRemoved = fromVC.get_first_property(ICAL_ANY_PROPERTY); propToBeRemoved != NULL;
+ for (propToBeRemoved = fromVC.get_first_property(ICAL_ANY_PROPERTY);
+ propToBeRemoved != NULL;
propToBeRemoved = fromVC.get_next_property(ICAL_ANY_PROPERTY)) {
/* loop through properties from this component */
@@ -573,7 +568,7 @@ bool VComponent::remove(VComponent &fromVC, bool ignoreValue)
if (ignoreValue) {
this->remove_property(p);
} else {
- if (*p == *propToBeRemoved) {
+ if (p == propToBeRemoved) {
this->remove_property(p);
break;
}
@@ -626,8 +621,11 @@ bool VComponent::update(VComponent &fromC, bool removeMissing)
thisProp = new ICalProperty(prop->isa());
this->add_property(thisProp);
}
- ICalValue *value = new ICalValue(*(prop->get_value())); // clone the value
+ ICalValue *tempValue = prop->get_value();
+ ICalValue *value = new ICalValue(*tempValue); // clone the value
thisProp->set_value(*value);
+ delete tempValue;
+ delete value;
}
/* recursively updating sub-components */
@@ -663,6 +661,7 @@ bool VComponent::add(VComponent &fromC)
/* clone another property */
ICalProperty *p = new ICalProperty(*prop);
add_property(p);
+ delete p;
}
/* sub-components next */
@@ -674,6 +673,7 @@ bool VComponent::add(VComponent &fromC)
err = c->add(*comp);
_unused(err);
add_component(c);
+ delete c;
}
return true;
@@ -903,9 +903,6 @@ VAlarm::VAlarm(const std::string &str) : VComponent(str)
icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *tr)
{
- struct icaltimetype tt;
- ICalParameter *related_param;
-
ICalPropertyTmpPtr trigger_prop = this->get_first_property(ICAL_TRIGGER_PROPERTY);
// all VALARMs must have a TRIGGER
@@ -915,9 +912,8 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
*tr = trigger_prop->get_trigger();
- tt = icaltime_null_time();
-
- if (icaltime_is_null_time(tr->time)) {
+ if (icaltime_is_null_time(tr->time) == 1) {
+ struct icaltimetype tt = icaltime_null_time();
// relative time trigger
@@ -925,14 +921,14 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
// TRIGGER;RELATED=START:-P15M 15 minutes before START
// get RELATED parameter
- related_param = trigger_prop->get_first_parameter(ICAL_RELATED_PARAMETER);
+ ICalParameter *related_param = trigger_prop->get_first_parameter(ICAL_RELATED_PARAMETER);
- if (related_param && related_param->is_valid()) {
+ if ((related_param != NULL) && related_param->is_valid()) {
// get RELATED parameter value
icalparameter_related related = related_param->get_related();
- if (related) {
+ if (related != 0) {
switch (related) {
case ICAL_RELATED_END:
if (c.isa() == ICAL_VEVENT_COMPONENT) {
@@ -941,14 +937,14 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
// If a recurrenceid exists, use that to calculate the
// dtend from the dtstart.
struct icaltimetype recur_time = c.get_recurrenceid();
- if (!(icaltime_is_null_time(recur_time))) {
+ if (icaltime_is_null_time(recur_time) != 1) {
struct icaldurationtype dur = icaltime_subtract(c.get_dtstart(), tt);
tt = icaltime_add(recur_time, dur);
}
} else if (c.isa() == ICAL_VTODO_COMPONENT) {
tt = c.get_due();
struct icaltimetype recur_time = c.get_recurrenceid();
- if (!(icaltime_is_null_time(recur_time))) {
+ if (icaltime_is_null_time(recur_time) != 1) {
tt = recur_time;
}
}
@@ -960,7 +956,7 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
default:
tt = c.get_dtstart();
struct icaltimetype recur_time = c.get_recurrenceid();
- if (!(icaltime_is_null_time(recur_time))) {
+ if (icaltime_is_null_time(recur_time) != 1) {
tt = recur_time;
}
break;
@@ -972,7 +968,7 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
// due for VTODO to calculate trigger time.
// If a recur time exists, use that. Recur time trumps dtstart or due.
struct icaltimetype recur_time = c.get_recurrenceid();
- if (!(icaltime_is_null_time(recur_time))) {
+ if (icaltime_is_null_time(recur_time) != 1) {
tt = recur_time;
} else if (c.isa() == ICAL_VEVENT_COMPONENT) {
tt = c.get_dtstart();
@@ -981,12 +977,12 @@ icalrequeststatus VAlarm::getTriggerTime(VComponent &c, struct icaltriggertype *
}
}
- if (related_param) {
+ if (related_param != NULL) {
free(related_param);
}
// malformed? encapsulating VEVENT or VTODO MUST have DTSTART/DTEND
- if (icaltime_is_null_time(tt)) {
+ if (icaltime_is_null_time(tt) == 1) {
return ICAL_3_1_INVPROPVAL_STATUS;
};
diff --git a/src/libical/vcomponent_cxx.h b/src/libical/vcomponent_cxx.h
index fd8823d5..73731f6a 100644
--- a/src/libical/vcomponent_cxx.h
+++ b/src/libical/vcomponent_cxx.h
@@ -34,7 +34,7 @@ extern "C"
namespace LibICal
{
- class ICalProperty;
+class ICalProperty;
/**
* @class VComponent
@@ -44,57 +44,57 @@ namespace LibICal
* propagated via this exception type.
*/
- class LIBICAL_ICAL_EXPORT VComponent
- {
- public:
- VComponent() throw(icalerrorenum);
- VComponent(const VComponent &) throw(icalerrorenum);
- VComponent & operator=(const VComponent &) throw(icalerrorenum);
- virtual ~ VComponent();
+class LIBICAL_ICAL_EXPORT VComponent
+{
+public:
+ VComponent() throw(icalerrorenum);
+ VComponent(const VComponent &) throw(icalerrorenum);
+ VComponent &operator=(const VComponent &) throw(icalerrorenum);
+ virtual ~VComponent();
- explicit VComponent(icalcomponent *v) throw(icalerrorenum);
- explicit VComponent(const std::string & str) throw(icalerrorenum);
- explicit VComponent(const icalcomponent_kind & kind) throw(icalerrorenum);
+ explicit VComponent(icalcomponent *v) throw(icalerrorenum);
+ explicit VComponent(const std::string &str) throw(icalerrorenum);
+ explicit VComponent(const icalcomponent_kind &kind) throw(icalerrorenum);
- operator icalcomponent *()
- {
- return imp;
- }
+ operator icalcomponent *()
+ {
+ return imp;
+ }
- void new_from_string(const std::string & str);
+ void new_from_string(const std::string &str);
- // detach imp to this object. use with caution. it would cause
- // memory leak if you are not careful.
- void detach();
+ // detach imp to this object. use with caution. it would cause
+ // memory leak if you are not careful.
+ void detach();
- public:
- std::string as_ical_string() throw(icalerrorenum);
- bool is_valid();
- icalcomponent_kind isa();
- int isa_component(void *component);
+public:
+ std::string as_ical_string() throw(icalerrorenum);
+ bool is_valid();
+ icalcomponent_kind isa();
+ int isa_component(void *component);
- /// Working with properties
- void add_property(ICalProperty * property);
- void remove_property(ICalProperty * property);
- int count_properties(const icalproperty_kind & kind);
+ /// Working with properties
+ void add_property(ICalProperty *property);
+ void remove_property(ICalProperty *property);
+ int count_properties(const icalproperty_kind &kind);
- // Iterate through the properties
- ICalProperty *get_current_property();
- ICalProperty *get_first_property(const icalproperty_kind & kind);
- ICalProperty *get_next_property(const icalproperty_kind & kind);
+ // Iterate through the properties
+ ICalProperty *get_current_property();
+ ICalProperty *get_first_property(const icalproperty_kind &kind);
+ ICalProperty *get_next_property(const icalproperty_kind &kind);
- // Working with components
+ // Working with components
/**
* Return the first VEVENT, VTODO or VJOURNAL sub-component if
- * it is one of those types
+ * it is one of those types
*/
- VComponent *get_inner();
+ VComponent *get_inner();
- void add_component(VComponent * child);
- void remove_component(VComponent * child);
- int count_components(const icalcomponent_kind & kind);
+ void add_component(VComponent *child);
+ void remove_component(VComponent *child);
+ int count_components(const icalcomponent_kind &kind);
/**
* Iteration Routines. There are two forms of iterators,
@@ -102,36 +102,36 @@ namespace LibICal
* are almost completely sufficient, but they fail badly when
* you want to construct a loop that removes components from
* the container.
- */
+ */
- /// Iterate through components
- VComponent *get_current_component();
- VComponent *get_first_component(const icalcomponent_kind & kind);
- VComponent *get_next_component(const icalcomponent_kind & kind);
+ /// Iterate through components
+ VComponent *get_current_component();
+ VComponent *get_first_component(const icalcomponent_kind &kind);
+ VComponent *get_next_component(const icalcomponent_kind &kind);
- /// Using external iterators
- icalcompiter begin_component(const icalcomponent_kind & kind);
- icalcompiter end_component(const icalcomponent_kind & kind);
- VComponent *next(icalcompiter * i);
- VComponent *prev(icalcompiter * i);
- VComponent *current(icalcompiter * i);
+ /// Using external iterators
+ icalcompiter begin_component(const icalcomponent_kind &kind);
+ icalcompiter end_component(const icalcomponent_kind &kind);
+ VComponent *next(icalcompiter *i);
+ VComponent *prev(icalcompiter *i);
+ VComponent *current(icalcompiter *i);
- /// Working with embedded error properties
- int count_errors();
+ /// Working with embedded error properties
+ int count_errors();
- /// Remove all X-LIC-ERROR properties
- void strip_errors();
+ /// Remove all X-LIC-ERROR properties
+ void strip_errors();
- /// Convert some X-LIC-ERROR properties into RETURN-STATUS properties
- void convert_errors();
+ /// Convert some X-LIC-ERROR properties into RETURN-STATUS properties
+ void convert_errors();
- /// Kind conversion routines
- static icalcomponent_kind string_to_kind(const std::string & str);
- static std::string kind_to_string(const icalcomponent_kind & kind);
+ /// Kind conversion routines
+ static icalcomponent_kind string_to_kind(const std::string &str);
+ static std::string kind_to_string(const icalcomponent_kind &kind);
- public:
- struct icaltimetype get_dtstart() const;
- void set_dtstart(const struct icaltimetype &v);
+public:
+ struct icaltimetype get_dtstart() const;
+ void set_dtstart(const struct icaltimetype &v);
/** For the icalcomponent routines only, dtend and duration
* are tied together. If you call the set routine for one and
@@ -142,227 +142,225 @@ namespace LibICal
* one and the other exists, the routine will calculate the
* return value. If you call a set routine and neither
* exists, the routine will create the appropriate property
- */
+ */
- struct icaltimetype get_dtend() const;
- void set_dtend(const struct icaltimetype &v);
+ struct icaltimetype get_dtend() const;
+ void set_dtend(const struct icaltimetype &v);
- struct icaltimetype get_due() const;
- void set_due(const struct icaltimetype &v);
+ struct icaltimetype get_due() const;
+ void set_due(const struct icaltimetype &v);
- struct icaldurationtype get_duration() const;
- void set_duration(const struct icaldurationtype &v);
+ struct icaldurationtype get_duration() const;
+ void set_duration(const struct icaldurationtype &v);
- icalproperty_method get_method() const;
- void set_method(const icalproperty_method & method);
+ icalproperty_method get_method() const;
+ void set_method(const icalproperty_method &method);
- struct icaltimetype get_dtstamp() const;
- void set_dtstamp(const struct icaltimetype &v);
+ struct icaltimetype get_dtstamp() const;
+ void set_dtstamp(const struct icaltimetype &v);
- std::string get_summary() const;
- void set_summary(const std::string & v);
+ std::string get_summary() const;
+ void set_summary(const std::string &v);
- std::string get_location() const;
- void set_location(const std::string & v);
+ std::string get_location() const;
+ void set_location(const std::string &v);
- std::string get_description() const;
- void set_description(const std::string & v);
+ std::string get_description() const;
+ void set_description(const std::string &v);
- std::string get_comment() const;
- void set_comment(const std::string & v);
+ std::string get_comment() const;
+ void set_comment(const std::string &v);
- std::string get_uid() const;
- void set_uid(const std::string & v);
+ std::string get_uid() const;
+ void set_uid(const std::string &v);
- std::string get_relcalid() const;
- void set_relcalid(const std::string & v);
+ std::string get_relcalid() const;
+ void set_relcalid(const std::string &v);
- struct icaltimetype get_recurrenceid() const;
- void set_recurrenceid(const struct icaltimetype &v);
+ struct icaltimetype get_recurrenceid() const;
+ void set_recurrenceid(const struct icaltimetype &v);
- int get_sequence() const;
- void set_sequence(const int &v);
+ int get_sequence() const;
+ void set_sequence(const int &v);
- int get_status() const;
- void set_status(const enum icalproperty_status &v);
+ int get_status() const;
+ void set_status(const enum icalproperty_status &v);
- public:
+public:
/**
* For VCOMPONENT: Return a reference to the first VEVENT,
* VTODO, or VJOURNAL
- */
- VComponent * get_first_real_component();
+ */
+ VComponent *get_first_real_component();
/**
* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the
* start and end times of an event in UTC
*/
- virtual struct icaltime_span get_span();
+ virtual struct icaltime_span get_span();
- int recurrence_is_excluded(struct icaltimetype *dtstart, struct icaltimetype *recurtime);
+ int recurrence_is_excluded(struct icaltimetype *dtstart, struct icaltimetype *recurtime);
- public:
- /**
- helper functions for adding/removing/updating property and
- sub-components */
+public:
+ /* helper functions for adding/removing/updating property and sub-components */
- /// Note: the VComponent kind have to be the same
+ /// Note: the VComponent kind have to be the same
- bool remove(VComponent &, bool ignoreValue);
- bool update(VComponent &, bool removeMissing);
- bool add(VComponent &);
+ bool remove(VComponent &, bool ignoreValue);
+ bool update(VComponent &, bool removeMissing);
+ bool add(VComponent &);
- private:
- /* Internal operations. They are private, and you should not be using them. */
- VComponent * get_parent();
- void set_parent(VComponent * parent);
+private:
+ /* Internal operations. They are private, and you should not be using them. */
+ VComponent *get_parent();
+ void set_parent(VComponent *parent);
- char *quote_ical_string(char *str);
+ char *quote_ical_string(char *str);
- private:
- icalcomponent *imp;
- };
+private:
+ icalcomponent *imp;
+};
- class LIBICAL_ICAL_EXPORT VCalendar:public VComponent
- {
- public:
- VCalendar();
- VCalendar(const VCalendar &);
- VCalendar & operator=(const VCalendar &);
- ~VCalendar();
+class LIBICAL_ICAL_EXPORT VCalendar: public VComponent
+{
+public:
+ VCalendar();
+ VCalendar(const VCalendar &);
+ VCalendar &operator=(const VCalendar &);
+ ~VCalendar();
- explicit VCalendar(icalcomponent *v);
- explicit VCalendar(const std::string & str);
- };
+ explicit VCalendar(icalcomponent *v);
+ explicit VCalendar(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VEvent:public VComponent
- {
- public:
- VEvent();
- VEvent(const VEvent &);
- VEvent & operator=(const VEvent &);
- ~VEvent();
+class LIBICAL_ICAL_EXPORT VEvent: public VComponent
+{
+public:
+ VEvent();
+ VEvent(const VEvent &);
+ VEvent &operator=(const VEvent &);
+ ~VEvent();
- explicit VEvent(icalcomponent *v);
- explicit VEvent(const std::string & str);
- };
+ explicit VEvent(icalcomponent *v);
+ explicit VEvent(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VToDo:public VComponent
- {
- public:
- VToDo();
- VToDo(const VToDo &);
- VToDo & operator=(const VToDo &);
- ~VToDo();
+class LIBICAL_ICAL_EXPORT VToDo: public VComponent
+{
+public:
+ VToDo();
+ VToDo(const VToDo &);
+ VToDo &operator=(const VToDo &);
+ ~VToDo();
- explicit VToDo(icalcomponent *v);
- explicit VToDo(const std::string & str);
- };
+ explicit VToDo(icalcomponent *v);
+ explicit VToDo(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VAgenda:public VComponent
- {
- public:
- VAgenda();
- VAgenda(const VAgenda &);
- VAgenda & operator=(const VAgenda &);
- ~VAgenda();
+class LIBICAL_ICAL_EXPORT VAgenda: public VComponent
+{
+public:
+ VAgenda();
+ VAgenda(const VAgenda &);
+ VAgenda &operator=(const VAgenda &);
+ ~VAgenda();
- explicit VAgenda(icalcomponent *v);
- explicit VAgenda(const std::string & str);
- };
+ explicit VAgenda(icalcomponent *v);
+ explicit VAgenda(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VQuery:public VComponent
- {
- public:
- VQuery();
- VQuery(const VQuery &);
- VQuery & operator=(const VQuery &);
- ~VQuery();
+class LIBICAL_ICAL_EXPORT VQuery: public VComponent
+{
+public:
+ VQuery();
+ VQuery(const VQuery &);
+ VQuery &operator=(const VQuery &);
+ ~VQuery();
- explicit VQuery(icalcomponent *v);
- explicit VQuery(const std::string & str);
- };
+ explicit VQuery(icalcomponent *v);
+ explicit VQuery(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VJournal:public VComponent
- {
- public:
- VJournal();
- VJournal(const VJournal &);
- VJournal & operator=(const VJournal &);
- ~VJournal();
+class LIBICAL_ICAL_EXPORT VJournal: public VComponent
+{
+public:
+ VJournal();
+ VJournal(const VJournal &);
+ VJournal &operator=(const VJournal &);
+ ~VJournal();
- explicit VJournal(icalcomponent *v);
- explicit VJournal(const std::string & str);
- };
+ explicit VJournal(icalcomponent *v);
+ explicit VJournal(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VAlarm:public VComponent
- {
- public:
- VAlarm();
- VAlarm(const VAlarm &);
- VAlarm & operator=(const VAlarm &);
- ~VAlarm();
+class LIBICAL_ICAL_EXPORT VAlarm: public VComponent
+{
+public:
+ VAlarm();
+ VAlarm(const VAlarm &);
+ VAlarm &operator=(const VAlarm &);
+ ~VAlarm();
- explicit VAlarm(icalcomponent *v);
- explicit VAlarm(const std::string & str);
+ explicit VAlarm(icalcomponent *v);
+ explicit VAlarm(const std::string &str);
/**
* compute the absolute trigger time for this alarm. trigger
* may be related to the containing component c. the result
* is populated in tr->time
*/
- icalrequeststatus getTriggerTime(VComponent & c, struct icaltriggertype *tr);
- };
+ icalrequeststatus getTriggerTime(VComponent &c, struct icaltriggertype *tr);
+};
- class LIBICAL_ICAL_EXPORT VFreeBusy:public VComponent
- {
- public:
- VFreeBusy();
- VFreeBusy(const VFreeBusy &);
- VFreeBusy & operator=(const VFreeBusy &);
- ~VFreeBusy();
+class LIBICAL_ICAL_EXPORT VFreeBusy: public VComponent
+{
+public:
+ VFreeBusy();
+ VFreeBusy(const VFreeBusy &);
+ VFreeBusy &operator=(const VFreeBusy &);
+ ~VFreeBusy();
- explicit VFreeBusy(icalcomponent *v);
- explicit VFreeBusy(const std::string & str);
- };
+ explicit VFreeBusy(icalcomponent *v);
+ explicit VFreeBusy(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT VTimezone:public VComponent
- {
- public:
- VTimezone();
- VTimezone(const VTimezone &);
- VTimezone & operator=(const VTimezone &);
- ~VTimezone();
+class LIBICAL_ICAL_EXPORT VTimezone: public VComponent
+{
+public:
+ VTimezone();
+ VTimezone(const VTimezone &);
+ VTimezone &operator=(const VTimezone &);
+ ~VTimezone();
- explicit VTimezone(icalcomponent *v);
- explicit VTimezone(const std::string & str);
- };
+ explicit VTimezone(icalcomponent *v);
+ explicit VTimezone(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT XStandard:public VComponent
- {
- public:
- XStandard();
- XStandard(const XStandard &);
- XStandard & operator=(const XStandard &);
- ~XStandard();
+class LIBICAL_ICAL_EXPORT XStandard: public VComponent
+{
+public:
+ XStandard();
+ XStandard(const XStandard &);
+ XStandard &operator=(const XStandard &);
+ ~XStandard();
- explicit XStandard(icalcomponent *v);
- explicit XStandard(const std::string & str);
- };
+ explicit XStandard(icalcomponent *v);
+ explicit XStandard(const std::string &str);
+};
- class LIBICAL_ICAL_EXPORT XDaylight:public VComponent
- {
- public:
- XDaylight();
- XDaylight(const XDaylight &);
- XDaylight & operator=(const XDaylight &);
- ~XDaylight();
+class LIBICAL_ICAL_EXPORT XDaylight: public VComponent
+{
+public:
+ XDaylight();
+ XDaylight(const XDaylight &);
+ XDaylight &operator=(const XDaylight &);
+ ~XDaylight();
- explicit XDaylight(icalcomponent *v);
- explicit XDaylight(const std::string & str);
- };
+ explicit XDaylight(icalcomponent *v);
+ explicit XDaylight(const std::string &str);
+};
-} // namespace LibICal;
+} // namespace LibICal;
typedef ICPointerHolder < LibICal::VComponent > VComponentTmpPtr;
diff --git a/src/libicalss/icalbdbset.c b/src/libicalss/icalbdbset.c
index 523eceb9..e881cd2f 100644
--- a/src/libicalss/icalbdbset.c
+++ b/src/libicalss/icalbdbset.c
@@ -31,10 +31,7 @@
#define MAX_RETRY 5
-/* these are just stub functions */
-icalerrorenum icalbdbset_create_cluster(const char *path);
-int icalbdbset_cget(DBC *dbcp, DBT *key, DBT *data, u_int32_t access_method);
-
+static int _compare_ids(const char *compid, const char *matchid);
static int _compare_keys(DB *dbp, const DBT *a, const DBT *b);
/** Default options used when NULL is passed to icalset_new() **/
@@ -1108,7 +1105,7 @@ struct icalbdbset_id icalbdbset_get_id(icalcomponent *comp)
p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);
if (p == 0) {
- id.recurrence_id = 0;
+ id.recurrence_id = NULL;
} else {
icalvalue *v;
@@ -1125,6 +1122,21 @@ struct icalbdbset_id icalbdbset_get_id(icalcomponent *comp)
component. Currently, it just matches based on UID and
RECURRENCE-ID */
+static int _compare_ids(const char *compid, const char *matchid)
+{
+ if (compid != NULL && matchid != NULL) {
+ if (strcmp(compid, matchid) == 0) {
+ return 1;
+ }
+ }
+
+ if (compid == NULL && matchid == NULL) {
+ return 1;
+ }
+
+ return 0;
+}
+
icalcomponent *icalbdbset_fetch_match(icalset *set, icalcomponent *comp)
{
icalbdbset *bset = (icalbdbset *) set;
@@ -1141,9 +1153,8 @@ icalcomponent *icalbdbset_fetch_match(icalset *set, icalcomponent *comp)
match_id = icalbdbset_get_id(match);
- if (strcmp(comp_id.uid, match_id.uid) == 0 &&
- (comp_id.recurrence_id == 0 ||
- strcmp(comp_id.recurrence_id, match_id.recurrence_id) == 0)) {
+ if (_compare_ids(comp_id.uid, match_id.uid) &&
+ _compare_ids(comp_id.recurrence_id, match_id.recurrence_id)) {
/* HACK. What to do with SEQUENCE? */
diff --git a/src/libicalss/icaldirset.c b/src/libicalss/icaldirset.c
index 064eb60d..bbf4566a 100644
--- a/src/libicalss/icaldirset.c
+++ b/src/libicalss/icaldirset.c
@@ -130,6 +130,7 @@ static icalerrorenum icaldirset_read_directory(icaldirset *dset)
}
/* load all of the cluster names in the directory list */
+ /* cppcheck-suppress readdirCalled since readdir is recommended */
for (de = readdir(dp); de != 0; de = readdir(dp)) {
/* Remove known directory names '.' and '..' */
diff --git a/src/libicalss/icalfileset.c b/src/libicalss/icalfileset.c
index cc56003c..391e6496 100644
--- a/src/libicalss/icalfileset.c
+++ b/src/libicalss/icalfileset.c
@@ -18,7 +18,7 @@
The Original Code is eric. The Initial Developer of the Original
Code is Eric Busboom
======================================================================*/
-
+//krazy:excludeall=cpp
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -38,13 +38,13 @@
/** Default options used when NULL is passed to icalset_new() **/
icalfileset_options icalfileset_options_default = { O_RDWR | O_CREAT, 0644, 0, NULL };
+static int _compare_ids(const char *compid, const char *matchid);
+
static int icalfileset_lock(icalfileset *set);
static int icalfileset_unlock(icalfileset *set);
static icalerrorenum icalfileset_read_file(icalfileset *set, int mode);
static long icalfileset_filesize(icalfileset *set);
-icalerrorenum icalfileset_create_cluster(const char *path);
-
icalset *icalfileset_new(const char *path)
{
return icalset_new(ICAL_FILE_SET, path, &icalfileset_options_default);
@@ -600,7 +600,7 @@ static struct icalfileset_id icalfileset_get_id(icalcomponent *comp)
p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);
if (p == 0) {
- id.recurrence_id = 0;
+ id.recurrence_id = NULL;
} else {
icalvalue *v;
@@ -616,6 +616,22 @@ static struct icalfileset_id icalfileset_get_id(icalcomponent *comp)
/* Find the component that is related to the given
component. Currently, it just matches based on UID and
RECURRENCE-ID */
+
+static int _compare_ids(const char *compid, const char *matchid)
+{
+ if (compid != NULL && matchid != NULL) {
+ if (strcmp(compid, matchid) == 0) {
+ return 1;
+ }
+ }
+
+ if (compid == NULL && matchid == NULL) {
+ return 1;
+ }
+
+ return 0;
+}
+
icalcomponent *icalfileset_fetch_match(icalset *set, icalcomponent *comp)
{
icalfileset *fset = (icalfileset *) set;
@@ -632,9 +648,8 @@ icalcomponent *icalfileset_fetch_match(icalset *set, icalcomponent *comp)
match_id = icalfileset_get_id(match);
- if (strcmp(comp_id.uid, match_id.uid) == 0 &&
- (comp_id.recurrence_id == 0 ||
- strcmp(comp_id.recurrence_id, match_id.recurrence_id) == 0)) {
+ if (_compare_ids(comp_id.uid, match_id.uid) &&
+ _compare_ids(comp_id.recurrence_id, match_id.recurrence_id)) {
/* HACK. What to do with SEQUENCE? */
diff --git a/src/libicalss/icalmessage.c b/src/libicalss/icalmessage.c
index e5870dc7..ec88b57e 100644
--- a/src/libicalss/icalmessage.c
+++ b/src/libicalss/icalmessage.c
@@ -249,6 +249,7 @@ icalcomponent *icalmessage_new_delegate_request(icalcomponent *c,
icalcomponent *reply;
icalproperty *attendee;
icalcomponent *inner;
+ icalparameter *delegateeParam;
icalerror_check_arg_rz(c, "c");
@@ -267,20 +268,14 @@ icalcomponent *icalmessage_new_delegate_request(icalcomponent *c,
icalproperty_set_parameter(attendee, icalparameter_new_delegatedto(delegatee));
+ delegateeParam = icalparameter_new_delegatedfrom(icalproperty_get_attendee(attendee));
icalcomponent_add_property(
inner,
- icalproperty_vanew_attendee(
- delegatee,
- icalparameter_new_delegatedfrom(icalproperty_get_attendee(attendee)), 0));
-
+ icalproperty_vanew_attendee(delegatee, delegateeParam, 0));
+ icalparameter_free(delegateeParam);
return reply;
}
-icalcomponent *icalmessage_new_cancel_event(icalcomponent *c, const char *user, const char *msg);
-icalcomponent *icalmessage_new_cancel_instance(icalcomponent *c,
- const char *user, const char *msg);
-icalcomponent *icalmessage_new_cancel_all(icalcomponent *c, const char *user, const char *msg);
-
icalcomponent *icalmessage_new_error_reply(icalcomponent *c,
const char *user,
const char *msg,
diff --git a/src/libicalss/icalset.c b/src/libicalss/icalset.c
index 261ea472..f1c048dd 100644
--- a/src/libicalss/icalset.c
+++ b/src/libicalss/icalset.c
@@ -152,7 +152,7 @@ static int load(const char *file)
return 0;
}
- if ((inith = (fptr) dlsym(modh, "InitModule")) == 0) {
+ if ((inith = (fptr)dlsym(modh, "InitModule")) == 0) {
perror("dlsym");
return 0;
}
@@ -187,6 +187,7 @@ int icalset_loaddir(const char *path)
return 0;
}
+ /* cppcheck-suppress readdirCalled since readdir is recommended */
while ((dp = readdir(d)) != 0) {
if (strncmp(dp->d_name, "mod_", 4)) {
continue;
@@ -244,7 +245,7 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
}
for (e = pvl_head(icalset_kinds); e != 0; e = pvl_next(e)) {
- impl = (icalset *) pvl_data(e);
+ impl = (icalset *)pvl_data(e);
if (impl->kind == kind) {
break;
}
@@ -254,8 +255,8 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
return (NULL);
}
- data = (icalset *) malloc(impl->size);
- if (data == (icalset *) NULL) {
+ data = (icalset *)malloc(impl->size);
+ if (data == (icalset *)NULL) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
errno = ENOMEM;
return 0;
@@ -269,8 +270,10 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
data->dsn = strdup(dsn);
#else
switch (kind) {
- case ICAL_FILE_SET:
- data = (icalset *) malloc(sizeof(icalfileset));
+ case ICAL_FILE_SET: {
+ icalfileset *fdata;
+ fdata = (icalfileset *)malloc(sizeof(icalfileset));
+ data = (icalset *)fdata;
if (data == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
errno = ENOMEM;
@@ -279,8 +282,11 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
memset(data, 0, sizeof(icalfileset));
*data = icalset_fileset_init;
break;
- case ICAL_DIR_SET:
- data = (icalset *) malloc(sizeof(icaldirset));
+ }
+ case ICAL_DIR_SET: {
+ icaldirset *ddata;
+ ddata = (icaldirset *)malloc(sizeof(icaldirset));
+ data = (icalset *)ddata;
if (data == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
errno = ENOMEM;
@@ -289,9 +295,12 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
memset(data, 0, sizeof(icaldirset));
*data = icalset_dirset_init;
break;
+ }
#if defined(WITH_BDB)
- case ICAL_BDB_SET:
- data = (icalset *) malloc(sizeof(icalbdbset));
+ case ICAL_BDB_SET: {
+ icalbdbset *bdata;
+ bdata = (icalbdbset *)malloc(sizeof(icalbdbset));
+ data = (icalset *)bdata;
if (data == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
errno = ENOMEM;
@@ -300,6 +309,7 @@ icalset *icalset_new(icalset_kind kind, const char *dsn, void *options)
memset(data, 0, sizeof(icalbdbset));
*data = icalset_bdbset_init;
break;
+ }
#endif
default:
diff --git a/src/libicalss/icalspanlist.c b/src/libicalss/icalspanlist.c
index f1832c20..f717eff2 100644
--- a/src/libicalss/icalspanlist.c
+++ b/src/libicalss/icalspanlist.c
@@ -244,7 +244,6 @@ void icalspanlist_dump(icalspanlist *sl)
}
}
-icalcomponent *icalspanlist_make_free_list(icalspanlist *sl);
icalcomponent *icalspanlist_make_busy_list(icalspanlist *sl);
/** @brief Find next free time span in a spanlist.
@@ -319,8 +318,6 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist *sl, struct icalt
return period;
}
-struct icalperiodtype icalspanlist_next_busy_time(icalspanlist *sl, struct icaltimetype t);
-
/** @brief Returns an hour-by-hour array of free/busy times over a
* given period.
*
diff --git a/src/libicalss/icalspanlist.h b/src/libicalss/icalspanlist.h
index aca4b44e..f6582f0b 100644
--- a/src/libicalss/icalspanlist.h
+++ b/src/libicalss/icalspanlist.h
@@ -40,19 +40,10 @@ LIBICAL_ICALSS_EXPORT icalspanlist *icalspanlist_new(icalset *set,
*/
LIBICAL_ICALSS_EXPORT void icalspanlist_free(icalspanlist *spl);
-/* Unimplemented functions */
-LIBICAL_ICALSS_EXPORT icalcomponent *icalspanlist_make_free_list(icalspanlist *sl);
-
-LIBICAL_ICALSS_EXPORT icalcomponent *icalspanlist_make_busy_list(icalspanlist *sl);
-
/** Get first next free time after time t. all times are in UTC. */
LIBICAL_ICALSS_EXPORT struct icalperiodtype icalspanlist_next_free_time(icalspanlist *sl,
struct icaltimetype t);
-/** Get first next busy time after time t. all times are in UTC. */
-LIBICAL_ICALSS_EXPORT struct icalperiodtype icalspanlist_next_busy_time(icalspanlist *sl,
- struct icaltimetype t);
-
LIBICAL_ICALSS_EXPORT void icalspanlist_dump(icalspanlist *s);
/** @brief Return a valid VFREEBUSY component for this span */
diff --git a/src/libicalss/icalspanlist_cxx.cpp b/src/libicalss/icalspanlist_cxx.cpp
index 08a41d69..e91441d4 100644
--- a/src/libicalss/icalspanlist_cxx.cpp
+++ b/src/libicalss/icalspanlist_cxx.cpp
@@ -32,13 +32,13 @@ using namespace LibICal;
*/
ICalSpanList::ICalSpanList() throw(icalerrorenum)
-: data(0)
+ : data(0)
{
throw icalerrno;
}
ICalSpanList::ICalSpanList(const ICalSpanList &v) throw(icalerrorenum)
- : data(v.data)
+ : data(v.data)
{
if (data == NULL) {
throw icalerrno;
@@ -46,9 +46,9 @@ ICalSpanList::ICalSpanList(const ICalSpanList &v) throw(icalerrorenum)
}
ICalSpanList::ICalSpanList(icalset *set, icaltimetype start, icaltimetype end) throw(icalerrorenum)
- : data(icalspanlist_new(set, start, end))
+ : data(icalspanlist_new(set, start, end))
{
- if (!data) {
+ if (data == NULL) {
throw icalerrno;
}
}
@@ -58,9 +58,9 @@ ICalSpanList::ICalSpanList(icalset *set, icaltimetype start, icaltimetype end) t
*/
ICalSpanList::ICalSpanList(icalcomponent *comp) throw(icalerrorenum)
- : data(icalspanlist_from_vfreebusy(comp))
+ : data(icalspanlist_from_vfreebusy(comp))
{
- if (!data) {
+ if (data == NULL) {
throw icalerrno;
}
}
@@ -69,9 +69,9 @@ ICalSpanList::ICalSpanList(icalcomponent *comp) throw(icalerrorenum)
@param comp A valid VComponent with a VFREEBUSY section
*/
ICalSpanList::ICalSpanList(VComponent &comp) throw(icalerrorenum)
- : data(icalspanlist_from_vfreebusy((icalcomponent *) comp))
+ : data(icalspanlist_from_vfreebusy(static_cast<icalcomponent *>(comp)))
{
- if (!data) {
+ if (data == NULL) {
throw icalerrno;
}
}
@@ -84,7 +84,7 @@ void ICalSpanList::dump()
/** Destructor */
ICalSpanList::~ICalSpanList()
{
- if (data) {
+ if (data == NULL) {
icalspanlist_free(data);
}
}
@@ -102,12 +102,12 @@ VComponent *ICalSpanList::get_vfreebusy(
VComponent *vcomp;
comp = icalspanlist_as_vfreebusy(data, organizer, attendee);
- if (comp == 0) {
+ if (comp == NULL) {
throw icalerrno;
}
vcomp = new VComponent(comp);
- if (vcomp == 0) {
+ if (vcomp == NULL) {
throw icalerrno;
}
@@ -134,8 +134,8 @@ std::vector<int> ICalSpanList::as_vector(int delta_t) throw(icalerrorenum)
matrix = icalspanlist_as_freebusy_matrix(data, delta_t);
- if (!matrix) {
- throw ICAL_USAGE_ERROR;
+ if (matrix == NULL) {
+ throw icalerrno;
}
while (matrix[i] != -1) {
diff --git a/src/libicalss/icalspanlist_cxx.h b/src/libicalss/icalspanlist_cxx.h
index 8a6445ec..1f44fc4f 100644
--- a/src/libicalss/icalspanlist_cxx.h
+++ b/src/libicalss/icalspanlist_cxx.h
@@ -35,7 +35,7 @@ extern "C"
namespace LibICal
{
- class VComponent;
+class VComponent;
/**
* This class wraps the icalspanlist routines in libicalss
@@ -44,44 +44,44 @@ namespace LibICal
* icalerrorenum. See icalerror.h for the complete list of exceptions
* that might be thrown.
*/
- class LIBICAL_ICALSS_EXPORT ICalSpanList
- {
- public:
- ICalSpanList() throw(icalerrorenum);
- ICalSpanList(const ICalSpanList &v) throw(icalerrorenum);
+class LIBICAL_ICALSS_EXPORT ICalSpanList
+{
+public:
+ ICalSpanList() throw(icalerrorenum);
+ ICalSpanList(const ICalSpanList &v) throw(icalerrorenum);
/** Construct an ICalSpanList from an icalset */
- ICalSpanList(icalset *set, icaltimetype start, icaltimetype end) throw(icalerrorenum);
+ ICalSpanList(icalset *set, icaltimetype start, icaltimetype end) throw(icalerrorenum);
/** Construct an ICalSpanList from the VFREEBUSY chunk of a icalcomponent */
- explicit ICalSpanList(icalcomponent *comp) throw(icalerrorenum);
+ explicit ICalSpanList(icalcomponent *comp) throw(icalerrorenum);
/** Construct an ICalSpanList from the VFREEBUSY chunk of a vcomponent */
- explicit ICalSpanList(VComponent &comp) throw(icalerrorenum);
+ explicit ICalSpanList(VComponent &comp) throw(icalerrorenum);
/** Destructor */
- ~ICalSpanList();
+ ~ICalSpanList();
/** Return a VFREEBUSY icalcomponent */
- VComponent *get_vfreebusy(const char *organizer, const char *attendee) throw(icalerrorenum);
+ VComponent *get_vfreebusy(const char *organizer, const char *attendee) throw(icalerrorenum);
- ICalSpanList &operator=(const ICalSpanList &) throw(icalerrorenum);
+ ICalSpanList &operator=(const ICalSpanList &) throw(icalerrorenum);
/** Return the base data when casting */
- operator icalspanlist *()
- {
- return data;
- }
+ operator icalspanlist *()
+ {
+ return data;
+ }
/** Return a vector of the number of events over delta t */
- std::vector < int >as_vector(int delta_t) throw(icalerrorenum);
+ std::vector < int >as_vector(int delta_t) throw(icalerrorenum);
/** Dump the spanlist to stdout */
- void dump();
+ void dump();
- private:
- icalspanlist *data;
- };
+private:
+ icalspanlist *data;
+};
} // namespace LibICal;
diff --git a/src/libicalss/icalsslexer.c b/src/libicalss/icalsslexer.c
index 8ad3164f..b92fcead 100644
--- a/src/libicalss/icalsslexer.c
+++ b/src/libicalss/icalsslexer.c
@@ -40,6 +40,10 @@
#include <stdlib.h>
#include <stddef.h> /* for ptrdiff_t */
+#ifndef __cplusplus
+extern int isatty(int);
+#endif /* __cplusplus */
+
#ifdef _WIN32_WCE
#include <io.h>
#endif
@@ -1514,10 +1518,6 @@ static void ss_load_buffer_state (void)
ssfree((void *) b );
}
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a ssrestart() or at EOF.
diff --git a/src/libicalvcal/vcc.c b/src/libicalvcal/vcc.c
index a9e7f2ea..0dfaa212 100644
--- a/src/libicalvcal/vcc.c
+++ b/src/libicalvcal/vcc.c
@@ -484,7 +484,7 @@ static void enterValues(const char *value)
p3 = (wchar_t *) vObjectUStringZValue(curProp);
free(p3);
setVObjectUStringZValue_(curProp,fakeUnicode(p2,0));
- deleteStr(p2);
+ free(p2);
} else {
setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
}
@@ -944,7 +944,7 @@ static char * lexGetDataFromBase64()
}
}
} /* while */
- DBG_(("db: bytesLen = %l\n", bytesLen));
+ DBG_(("db: bytesLen = %lu\n", (unsigned long)bytesLen));
/* kludge: all this won't be necessary if we have tree form
representation */
if (bytes) {
diff --git a/src/python/LibicalWrap.i b/src/python/LibicalWrap.i
index 62a5aa59..42827446 100644
--- a/src/python/LibicalWrap.i
+++ b/src/python/LibicalWrap.i
@@ -78,17 +78,11 @@ typedef int time_t;
%ignore icalmessage_new_cancel_instance(icalcomponent* c,
const char* user,
const char* msg);
-%ignore icalmime_as_mime_string(char* icalcomponent);
-%ignore icalparameter_is_valid(icalparameter* parameter);
%ignore icalparser_parse_value(icalvalue_kind kind,
const char* str, icalcomponent** errors);
%ignore icalrestriction_is_parameter_allowed(icalproperty_kind property,
icalparameter_kind parameter);
%ignore icalset_clear_select(icalset* set);
-%ignore icalspanlist_make_free_list(icalspanlist* sl);
-%ignore icalspanlist_make_busy_list(icalspanlist* sl);
-%ignore icalspanlist_next_busy_time(icalspanlist* sl,
- struct icaltimetype t);
%ignore icaltime_days_in_year (const int year);
%ignore icaltime_from_string_with_zone(const char* str,
const icaltimezone *zone);
@@ -109,9 +103,6 @@ typedef int time_t;
%ignore icalcomponent_get_span(icalcomponent* comp);
%ignore icalproperty_remove_parameter(icalproperty* prop, icalparameter_kind kind);
-// Can't wrap va_list
-%ignore icalproperty_add_parameters(struct icalproperty_impl *prop, va_list args);
-
#ifndef _DLOPEN_TEST
%ignore icalset_register_class(icalset *set);
#endif
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 83bafbc5..1df5bd85 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -46,50 +46,29 @@ endmacro()
#macro to build (but do not create a test)
macro(buildme _name _srcs)
add_executable(${_name} ${_srcs})
- if(NOT STATIC_ONLY)
- add_dependencies(${_name} ical icalss icalvcal)
- target_link_libraries(${_name} ical icalss icalvcal)
- if(WITH_CXX_BINDINGS)
- target_link_libraries(${_name} ical_cxx icalss_cxx)
- endif()
- else()
+ add_dependencies(${_name} ical icalss icalvcal)
+ if(NOT SHARED_ONLY)
add_dependencies(${_name} ical-static icalss-static icalvcal-static)
- if(NOT WIN32)
- target_link_libraries(${_name}
- ${CMAKE_BINARY_DIR}/lib/libical.a
- ${CMAKE_BINARY_DIR}/lib/libicalss.a
- ${CMAKE_BINARY_DIR}/lib/libicalvcal.a
- )
- else()
- target_link_libraries(${_name}
- ${CMAKE_BINARY_DIR}/bin/libical-static.lib
- ${CMAKE_BINARY_DIR}/bin/libicalss-static.lib
- ${CMAKE_BINARY_DIR}/bin/libicalvcal-static.lib
- )
- endif()
- target_link_libraries(${_name} ${CMAKE_THREAD_LIBS_INIT})
- if(ICU_FOUND)
- target_link_libraries(${_name} ${ICU_LIBRARY})
- endif()
- if(ICU_I18N_FOUND)
- target_link_libraries(${_name} ${ICU_I18N_LIBRARY})
- endif()
- if(WITH_BDB)
- target_link_libraries(${_name} ${BDB_LIBRARY})
- endif()
- if(WITH_CXX_BINDINGS)
- if(NOT WIN32)
- target_link_libraries(${_name}
- ${CMAKE_BINARY_DIR}/lib/libical_cxx.a
- ${CMAKE_BINARY_DIR}/lib/libicalss_cxx.a
- )
- else()
- target_link_libraries(${_name}
- ${CMAKE_BINARY_DIR}/bin/libical_cxx-static.lib
- ${CMAKE_BINARY_DIR}/bin/libicalss_cxx-static.lib
- )
- endif()
+ endif()
+ target_link_libraries(${_name} ical icalss icalvcal)
+
+ if(WITH_CXX_BINDINGS)
+ add_dependencies(${_name} ical_cxx icalss_cxx)
+ if(NOT SHARED_ONLY)
+ add_dependencies(${_name} ical_cxx-static icalss_cxx-static)
endif()
+ target_link_libraries(${_name} ical_cxx icalss_cxx)
+ endif()
+
+ target_link_libraries(${_name} ${CMAKE_THREAD_LIBS_INIT})
+ if(ICU_FOUND)
+ target_link_libraries(${_name} ${ICU_LIBRARY})
+ endif()
+ if(ICU_I18N_FOUND)
+ target_link_libraries(${_name} ${ICU_I18N_LIBRARY})
+ endif()
+ if(WITH_BDB)
+ target_link_libraries(${_name} ${BDB_LIBRARY})
endif()
endmacro()
diff --git a/src/test/icalrecur_test.c b/src/test/icalrecur_test.c
index fffaba1c..0d272d27 100644
--- a/src/test/icalrecur_test.c
+++ b/src/test/icalrecur_test.c
@@ -25,6 +25,7 @@
#endif
#include <libical/ical.h>
+#include <stdlib.h>
#if defined(HAVE_LIBICU)
#include <unicode/ucal.h>
@@ -494,6 +495,7 @@ int main(int argc, char *argv[])
}
icalrecur_iterator_free(ritr);
+ free(rrule.rscale);
}
fclose(fp);
diff --git a/src/test/icaltestparser.c b/src/test/icaltestparser.c
index 27e73d69..025b8cb1 100644
--- a/src/test/icaltestparser.c
+++ b/src/test/icaltestparser.c
@@ -102,6 +102,7 @@ int main(int argc, char *argv[])
line = icalparser_get_line(parser, read_stream);
c = icalparser_add_line(parser, line);
+ icalmemory_free_buffer(line);
if (c != 0) {
/*icalcomponent_convert_errors(c); */
@@ -112,5 +113,8 @@ int main(int argc, char *argv[])
} while (line != 0);
+ icalparser_free(parser);
+ fclose(stream);
+
return 0;
}
diff --git a/src/test/process.c b/src/test/process.c
index 5b01f87d..df83eb42 100644
--- a/src/test/process.c
+++ b/src/test/process.c
@@ -146,9 +146,7 @@ int main(int argc, char *argv[])
is 1 modulo 4, counterpropose for the first
available free time. Otherwise, deline the meeting */
- icalcomponent *overlaps;
-
- overlaps = icalclassify_find_overlaps(cal, c);
+ icalcomponent *overlaps = icalclassify_find_overlaps(cal, c);
if (overlaps == 0) {
/* No overlaps, book the meeting */
@@ -206,6 +204,8 @@ int main(int argc, char *argv[])
"this meeting. I am proposing a time that works better for me.");
(void)icalset_add_component(out, reply);
+ icalspanlist_free(spanl);
+ icalcomponent_free(newc);
} else {
/* Decline the meeting */
@@ -219,6 +219,7 @@ int main(int argc, char *argv[])
(void)icalset_add_component(out, reply);
}
}
+ icalcomponent_free(overlaps);
break;
}
case ICAL_XLICCLASS_PUBLISHFREEBUSY:{
diff --git a/src/test/regression-classify.c b/src/test/regression-classify.c
index 0af17667..d794dda6 100644
--- a/src/test/regression-classify.c
+++ b/src/test/regression-classify.c
@@ -26,8 +26,6 @@
#include <libicalss/icalss.h>
#include "regression.h"
-extern int VERBOSE;
-
/* Get a note about the purpose of the property*/
static const char *get_note(icalcomponent *c)
{
diff --git a/src/test/regression-cxx.cpp b/src/test/regression-cxx.cpp
index 91cb1539..f35e0cd4 100644
--- a/src/test/regression-cxx.cpp
+++ b/src/test/regression-cxx.cpp
@@ -92,7 +92,7 @@ void test_cxx(void)
ok("vEvent->as_ical_string()",
(vEvent->as_ical_string().c_str() != 0));
- if (VERBOSE) {
+ if (VERBOSE != 0) {
printf("Summary: %s\n", vEvent->get_summary().c_str());
printf("DTSTART: %s\n", icaltime_as_ical_string(vEvent->get_dtstart()));
printf("DTEND: %s\n", icaltime_as_ical_string(vEvent->get_dtend()));
@@ -102,10 +102,17 @@ void test_cxx(void)
printf("vcomponent: %s", vEvent->as_ical_string().c_str());
}
- VComponent ic(icalparser_parse_string((const char *)content));
+ delete descProp;
+ delete locationProp;
+ delete endProp;
+ delete startProp;
+ delete summProp;
+ delete vEvent;
+
+ VComponent ic(icalparser_parse_string(const_cast<const char *>(content)));
ok("Parsing component", (ic.is_valid()));
- if (VERBOSE) {
+ if (VERBOSE != 0) {
printf("%s\n", ic.as_ical_string().c_str());
}
@@ -113,17 +120,17 @@ void test_cxx(void)
// we need to unwrap it.
VEvent *sub_ic = dynamic_cast<VEvent *>(ic.get_first_component(ICAL_VEVENT_COMPONENT));
-
- int_is("Getting VEvent subcomponent",
- sub_ic->isa(),
- ICAL_VEVENT_COMPONENT);
-
- while (sub_ic != NULL) {
- if (VERBOSE) {
- printf("subcomponent: %s\n", sub_ic->as_ical_string().c_str());
+ if (sub_ic != NULL) {
+ int_is("Getting VEvent subcomponent",
+ sub_ic->isa(),
+ ICAL_VEVENT_COMPONENT);
+ while (sub_ic != NULL) {
+ if (VERBOSE != 0) {
+ printf("subcomponent: %s\n", sub_ic->as_ical_string().c_str());
+ }
+ delete sub_ic;
+ sub_ic = dynamic_cast<VEvent *>(ic.get_next_component(ICAL_VEVENT_COMPONENT));
}
-
- sub_ic = dynamic_cast<VEvent *>(ic.get_next_component(ICAL_VEVENT_COMPONENT));
}
VCalendar *cal = new VCalendar();
@@ -135,25 +142,31 @@ void test_cxx(void)
ICalProperty *prop = new ICalProperty(ICAL_OWNER_PROPERTY);
prop->set_owner(string("fred@flintstone.net"));
vAgenda->add_property(prop);
+ delete prop;
prop = new ICalProperty(ICAL_SUMMARY_PROPERTY);
prop->set_summary(string("CPMain"));
vAgenda->add_property(prop);
+ delete prop;
prop = new ICalProperty(ICAL_TZID_PROPERTY);
prop->set_tzid(string("America/Los_Angeles"));
vAgenda->add_property(prop);
+ delete prop;
cal->add_component(vAgenda);
ok("Complex VCALENDAR/VAGENDA", (cal->as_ical_string().c_str() != 0));
- if (VERBOSE) {
+ if (VERBOSE != 0) {
printf("vAgenda: %s\n", cal->as_ical_string().c_str());
}
+ delete vAgenda;
+ delete cal;
+
//FIXME: causes an uncaught exception runtime error on APPLE. unknown reason.
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) //krazy:exclude=cpp
int caughtException = 0;
try {
VComponent v = VComponent(string("HFHFHFHF"));
diff --git a/src/test/regression-storage.c b/src/test/regression-storage.c
index 7c04e822..0d356c49 100644
--- a/src/test/regression-storage.c
+++ b/src/test/regression-storage.c
@@ -191,6 +191,7 @@ void test_fileset_extended(void)
(void)icalfileset_add_component(cout, clone);
(void)icalfileset_commit(cout);
+ icalcomponent_free(clone);
icalset_free(cout);
}
@@ -593,8 +594,11 @@ struct calendar *unpack_calendar(char *str, size_t size)
/* title_size */
memcpy(&cal->title_size, str + cal->title_size_offset, sizeof(cal->title_size));
- if ((cal->title = (char *)malloc(sizeof(char) * cal->title_size)) == NULL)
+ if ((cal->title = (char *)malloc(sizeof(char) * cal->title_size)) == NULL) {
+ free(cal->vcalendar);
+ free(cal);
return 0;
+ }
/* title */
memcpy(cal->title, (char *)(str + cal->title_offset), cal->title_size);
@@ -610,7 +614,9 @@ char *parse_vcalendar(const DBT *dbt)
str = (char *)dbt->data;
cal = unpack_calendar(str, dbt->size);
- return cal->vcalendar;
+ str = cal->vcalendar;
+ free(cal);
+ return str;
}
#endif
diff --git a/src/test/regression-utils.c b/src/test/regression-utils.c
index 2d7337e7..bb06ca7f 100644
--- a/src/test/regression-utils.c
+++ b/src/test/regression-utils.c
@@ -34,6 +34,7 @@ const char *ical_timet_string(const time_t t)
{
struct tm tmp, stm;
+ /* cppcheck-suppress uninitvar */
if (gmtime_r(&t, &tmp)) {
stm = tmp;
} else {
diff --git a/src/test/regression.c b/src/test/regression.c
index e50e7fe5..2d6dfdd9 100644
--- a/src/test/regression.c
+++ b/src/test/regression.c
@@ -190,14 +190,15 @@ void test_values()
icalvalue_free(v);
icalvalue_free(copy);
- v = icalvalue_new_boolean(1);
- int_is("icalvalue_new_boolean(1)", icalvalue_get_boolean(v), 1);
+ v = icalvalue_new_boolean(0);
+ int_is("icalvalue_new_boolean(0)", icalvalue_get_boolean(v), 0);
+ str_is("icalvalue_as_ical_string()", icalvalue_as_ical_string(v), "FALSE");
icalvalue_set_boolean(v, 2);
ok("icalvalue_set_boolean(2)", (2 == icalvalue_get_boolean(v)));
- str_is("icalvalue_as_ical_string()", icalvalue_as_ical_string(v), "2");
+ str_is("icalvalue_as_ical_string()", icalvalue_as_ical_string(v), "TRUE");
copy = icalvalue_new_clone(v);
- str_is("icalvalue_new_clone()", icalvalue_as_ical_string(copy), "2");
+ str_is("icalvalue_new_clone()", icalvalue_as_ical_string(copy), "TRUE");
icalvalue_free(v);
icalvalue_free(copy);
@@ -449,10 +450,21 @@ const char *good_child =
" Common Name 4:Another Comment\r\n"
"X-LIC-ERROR;X-LIC-ERRORTYPE=COMPONENT-PARSE-ERROR:This is only a test\r\n" "END:VEVENT\r\n";
+const char *bad_child =
+ "BEGIN;\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n"
+ "TZNAME:\\r\n";
+
void test_components()
{
icalcomponent *c;
icalcomponent *child;
+ int estate;
c = icalcomponent_vanew(
ICAL_VCALENDAR_COMPONENT,
@@ -491,6 +503,13 @@ void test_components()
str_is("test results of child component", icalcomponent_as_ical_string(child), good_child);
icalcomponent_free(c);
+
+ estate = icalerror_get_errors_are_fatal();
+ icalerror_set_errors_are_fatal(0);
+ c = icalcomponent_new_from_string(bad_child);
+ ok("parse failed as expected", (c == NULL));
+ icalcomponent_free(c);
+ icalerror_set_errors_are_fatal(estate);
}
void test_memory()
@@ -1395,6 +1414,7 @@ void test_requeststat()
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_DEFAULT);
icalproperty_free(p);
+ icalcomponent_free(c);
}
void test_dtstart()
@@ -2036,7 +2056,7 @@ void test_fblist()
icalfileset_options options = { O_RDONLY, 0644, 0, NULL };
icalset *set = icalset_new(ICAL_FILE_SET, TEST_DATADIR "/spanlist.ics", &options);
struct icalperiodtype period;
- icalcomponent *comp;
+ icalcomponent *comp, *fbcomp;
int *foo;
int i;
@@ -2070,9 +2090,9 @@ void test_fblist()
"19980102T010000");
if (VERBOSE) {
- printf("%s\n",
- icalcomponent_as_ical_string(icalspanlist_as_vfreebusy(
- sl, "a@foo.com", "b@foo.com")));
+ fbcomp = icalspanlist_as_vfreebusy(sl, "a@foo.com", "b@foo.com");
+ printf("%s\n", icalcomponent_as_ical_string(fbcomp));
+ icalcomponent_free(fbcomp);
}
foo = icalspanlist_as_freebusy_matrix(sl, 3600);
@@ -2101,7 +2121,7 @@ void test_fblist()
char *strp = out_str;
for (i = 0; foo[i] != -1; i++) {
- snprintf(strp, 80, "%1d", foo[i]);
+ snprintf(strp, 79, "%1d", foo[i]);
strp++;
}
str_is("Checking freebusy validity", out_str, "1121110");
@@ -2156,14 +2176,11 @@ void test_fblist()
icalspanlist_dump(new_sl);
}
- if (sl)
- icalspanlist_free(sl);
+ icalspanlist_free(sl);
- if (new_sl)
- icalspanlist_free(new_sl);
+ icalspanlist_free(new_sl);
- if (comp)
- icalcomponent_free(comp);
+ icalcomponent_free(comp);
icalset_free(set);
}
@@ -2643,7 +2660,8 @@ void test_gauge_compare()
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART = '20000101T000001'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2663,7 +2681,8 @@ void test_gauge_compare()
assert(g != 0);
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
/* Less than */
@@ -2672,10 +2691,11 @@ void test_gauge_compare()
ok(str, (c != 0 && g != 0));
+ assert(g != 0);
int_is("compare", icalgauge_compare(g, c), 1);
- assert(g != 0);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART < '20000101T000002'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2697,7 +2717,8 @@ void test_gauge_compare()
assert(g != 0);
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART > '20000101T000002'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2718,7 +2739,8 @@ void test_gauge_compare()
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART >= '20000101T000003'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2739,7 +2761,8 @@ void test_gauge_compare()
assert(g != 0);
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART <= '20000101T000001'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2767,7 +2790,8 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART > '20000101T000000' and DTSTART < '20000102T000000'";
@@ -2783,7 +2807,8 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
icalcomponent_free(c);
@@ -2799,7 +2824,8 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE DTSTART > '20000101T000000' and DTSTART < '20000102T000000'";
@@ -2815,7 +2841,9 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
+
icalcomponent_free(c);
/* Complex comparisons */
@@ -2840,21 +2868,24 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE COMMENT = 'foo'";
g = icalgauge_new_from_sql((char *)str, 0);
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE COMMENT = 'foo' AND VALARM.DTSTART = '20000101T120000'";
g = icalgauge_new_from_sql((char *)str, 0);
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
str = "SELECT * FROM VEVENT WHERE COMMENT = 'bar' AND VALARM.DTSTART = '20000101T120000'";
g = icalgauge_new_from_sql((char *)str, 0);
@@ -2868,7 +2899,8 @@ void test_gauge_compare()
ok(str, (g != 0));
int_is("compare", icalgauge_compare(g, c), 1);
- icalgauge_free(g);
+ if (g != NULL)
+ icalgauge_free(g);
icalcomponent_free(c);
}
@@ -3474,6 +3506,7 @@ void test_property_parse()
printf("%s\n", str);
icalproperty_free(p);
+ icalcomponent_free(c);
}
void test_value_parameter()
@@ -3678,6 +3711,7 @@ void test_attach_url()
}
str_is("attach url", icalattach_get_url(attach), "foofile");
str_is("attach with url", icalcomponent_as_ical_string(ac), test_icalcomp_str_attachwithurl);
+ icalattach_unref(attach);
icalproperty_free(ap);
icalcomponent_free(ac);
}
@@ -3697,6 +3731,7 @@ void test_attach_data()
}
str_is("attach data", (const char *) icalattach_get_data(attach), "foofile");
str_is("attach with data", icalcomponent_as_ical_string(ac), test_icalcomp_str_attachwithdata);
+ icalattach_unref(attach);
icalproperty_free(ap);
icalcomponent_free(ac);
}
@@ -3779,6 +3814,7 @@ void test_recurrenceexcluded(void)
recurtime = icaltime_from_string("20080819T180000Z");
ok("Recurrence is excluded for UTC EXDATE",
icalproperty_recurrence_is_excluded(event, &dtstart, &recurtime));
+ icalcomponent_free(calendar);
}
void test_bad_dtstart_in_timezone(void)
diff --git a/src/test/regression.h b/src/test/regression.h
index 053628a7..2516a6d1 100644
--- a/src/test/regression.h
+++ b/src/test/regression.h
@@ -36,7 +36,6 @@ extern "C"
void create_new_component_with_va_args(void);
void create_simple_component(void);
void test_icalcomponent_get_span(void);
- void create_new_component_with_va_args(void);
/* regression-classify.c */
void test_classify(void);
diff --git a/src/test/stow.c b/src/test/stow.c
index 0da98d0f..449f5d94 100644
--- a/src/test/stow.c
+++ b/src/test/stow.c
@@ -144,6 +144,11 @@ icalcomponent *get_first_real_component(icalcomponent *comp)
char *make_mime(const char *to, const char *from, const char *subject,
const char *text_message, const char *method, const char *ical_message)
{
+ if ((to == NULL) || (from == NULL) || (subject == NULL) ||
+ (text_message == NULL) || (ical_message == NULL)) {
+ return NULL;
+ }
+
size_t mess_size =
strlen(to) +
strlen(from) + strlen(subject) + strlen(text_message) + strlen(ical_message) + TMPSIZE;
@@ -171,7 +176,7 @@ Content-type: text/plain\n\
Content-Description: Text description of error message\n\n\
%s\n\n--%s", content_id, text_message, boundary);
- if (ical_message != 0 && method != 0) {
+ if (method != 0) {
snprintf(mime_part_2, TMPSIZE, "Content-ID: %s\n\
Content-type: text/calendar; method=%s\n\
Content-Description: iCal component reply\n\n\
@@ -206,6 +211,7 @@ void return_failure(icalcomponent *comp, char *message, struct options_struct *o
char *local_attendee = opt->calid;
FILE *p;
const char *org_addr;
+ char *mime;
icalcomponent *inner = get_first_real_component(comp);
@@ -232,8 +238,12 @@ void return_failure(icalcomponent *comp, char *message, struct options_struct *o
exit(1);
}
- fputs(make_mime(org_addr, local_attendee, "iMIP error",
- message, "reply", icalcomponent_as_ical_string(comp)), p);
+ mime = make_mime(org_addr, local_attendee, "iMIP error",
+ message, "reply", icalcomponent_as_ical_string(comp));
+ if (mime) {
+ fputs(mime, p);
+ free(mime);
+ }
if (opt->errors == ERRORS_TO_ORGANIZER) {
pclose(p);
@@ -246,7 +256,11 @@ void return_error(icalcomponent *comp, char *message, struct options_struct *opt
_unused(comp);
_unused(opt);
- fputs(make_mime("Dest", "Source", "iMIP system failure", message, 0, 0), stdout);
+ char *mime = make_mime("Dest", "Source", "iMIP system failure", message, "", "");
+ if (mime) {
+ fputs(mime, stdout);
+ free(mime);
+ }
}
icalcomponent *make_reply(icalcomponent *comp, icalproperty *return_status,
@@ -309,6 +323,9 @@ int check_attendee(icalproperty *p, struct options_struct *opt)
const char *s = icalproperty_get_attendee(p);
char *lower_attendee = lowercase(s);
char *local_attendee = opt->calid;
+ char *start = lower_attendee;
+
+ int found = 0;
/* Check that attendee begins with "mailto:" */
if (strncmp(lower_attendee, "mailto:", 7) == 0) {
@@ -316,15 +333,12 @@ int check_attendee(icalproperty *p, struct options_struct *opt)
lower_attendee += 7;
if (strcmp(lower_attendee, local_attendee) == 0) {
- return 1;
+ found = 1;
}
-
- lower_attendee -= 7;
-
- free(lower_attendee);
}
- return 0;
+ free(start);
+ return found;
}
char static_component_error_str[MAXPATHLEN];
@@ -567,6 +581,7 @@ void get_options(int argc, char *argv[], struct options_struct *opt)
}
/* Find password entry for user */
+ /* cppcheck-suppress getpwentCalled as we don't care about multi-threaded in a test prog */
while ((pw = getpwent()) != 0) {
if (strcmp(user, pw->pw_name) == 0) {
break;
@@ -619,20 +634,20 @@ void get_options(int argc, char *argv[], struct options_struct *opt)
fprintf(stderr,
"%s: Failed to create calendar directory %s: %s\n",
program_name, facspath, strerror(errno));
+ free(facspath);
exit(1);
} else {
fprintf(stderr, "%s: Creating calendar directory %s\n", program_name, facspath);
- free(facspath);
}
} else if (type == REGULAR || type == ERROR) {
fprintf(stderr, "%s: Cannot create calendar directory %s\n",
program_name, facspath);
+ free(facspath);
exit(1);
}
- } else {
- free(facspath);
}
+ free(facspath);
}
}
@@ -718,6 +733,7 @@ icalcomponent *read_nonmime_component(struct options_struct * opt)
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, es);
if (comp != 0) {
+ icalparser_free(parser);
return comp;
}
@@ -727,6 +743,7 @@ icalcomponent *read_nonmime_component(struct options_struct * opt)
fclose(stream);
}
+ icalparser_free(parser);
return comp;
}
diff --git a/src/test/testmime.c b/src/test/testmime.c
index 6147650a..d16c379d 100644
--- a/src/test/testmime.c
+++ b/src/test/testmime.c
@@ -227,6 +227,7 @@ int main(int argc, char *argv[])
}
last = i;
+ assert(size > 0);
buf = malloc(size * 2);
assert(buf != 0);
@@ -236,7 +237,7 @@ int main(int argc, char *argv[])
memset(buf, 0, size * 2);
/* First insert some non-randomized lines */
non_rand = (unsigned int)(((float)rand() / (float)RAND_MAX) * last);
- for (i = 0; i < non_rand; i++) {
+ for (i = 0; i < last && i < non_rand; i++) {
strcat(buf, array[i]);
}
diff --git a/src/test/testvcal.c b/src/test/testvcal.c
index 3c0a0fbe..66e0e509 100644
--- a/src/test/testvcal.c
+++ b/src/test/testvcal.c
@@ -57,5 +57,6 @@ int main(int argc, char *argv[])
printf("%s\n", icalcomponent_as_ical_string(comp));
+ icalcomponent_free(comp);
return 0;
}
diff --git a/src/test/timezones.c b/src/test/timezones.c
index 0f99274c..0f834447 100644
--- a/src/test/timezones.c
+++ b/src/test/timezones.c
@@ -56,6 +56,8 @@ int main()
for (i = 0; i < timezones->num_elements; i++) {
zone = (icaltimezone *)icalarray_element_at(timezones, i);
zone_location = (char *)icaltimezone_get_location(zone);
+ if (!zone_location)
+ continue;
/*
* select this location for glibc: needs support for TZ=<location>
@@ -66,7 +68,7 @@ int main()
#else
new_tz[0] = '\0';
strncat(new_tz, "TZ=", 255);
- strncat(new_tz, zone_location, 255);
+ strncat(new_tz, zone_location, 255 - strlen(new_tz));
putenv(new_tz);
#endif
tzset();
@@ -164,5 +166,6 @@ int main()
}
}
+ icaltimezone_free_builtin_timezones();
return ret;
}
diff --git a/test-data/issue250.ics b/test-data/issue250.ics
new file mode 100644
index 00000000..7cd12759
--- /dev/null
+++ b/test-data/issue250.ics
@@ -0,0 +1,8 @@
+BEGIN;\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
+TZNAME:\\r\n
diff --git a/test-data/issue251.ics b/test-data/issue251.ics
new file mode 100644
index 00000000..1ebea030
--- /dev/null
+++ b/test-data/issue251.ics
@@ -0,0 +1,15 @@
+BEGIN:VCALENDAR
+VERSION:0;0
+PRODID:a
+CALSCALE:b
+METHOD:b
+a:
+BEGIN:VJOURJAL
+DTSTAMP:18640549T165845Z
+UID:b
+LAST-MODIFIED:18640529T011608z
+ORGANIZER;DIR="//";SE^T-BY="//";LAJGUAGE="a"://-
+RECURRENCE-ID;TZID="c":1860509T225504 *END:VJGURNAL
+BEGIN:Vb
+END:V"
+END:VCALENDAR
diff --git a/test-data/issue252.ics b/test-data/issue252.ics
new file mode 100644
index 00000000..4e586e46
--- /dev/null
+++ b/test-data/issue252.ics
Binary files differ
diff --git a/test-data/issue253.ics b/test-data/issue253.ics
new file mode 100644
index 00000000..052c0a88
--- /dev/null
+++ b/test-data/issue253.ics
Binary files differ