# # # patch "calendar/dateset.C" # from [91b5444a8184fc2eeaf921adc47fdc55732ab6b2] # to [47d669b2e0c8d760404084a3101ecc1c527612e6] # # patch "calendar/dateset.h" # from [48302f784a8de12f77c76f4b02a344aa14380b11] # to [3961d71b39f4a7be23dfb954b52370effa7172ce] # # patch "calendar/item.C" # from [53f19e759535e590214c976f121d316aff047899] # to [bfdc8ed4ea39fa402e0228d2bd21c018cebfb4ec] # # patch "calendar/item.h" # from [2a5c913c700e3af2e1f4c503be016db8bbfa6baa] # to [116553e50d9d4bb19025a402927347195772b55d] # # patch "item_tcl.C" # from [33a46326bcaa1a2f4308024ec052139cceecd465] # to [2cce178db5f8734d57fcdf993911760f4ecb25fc] # ============================================================ --- calendar/dateset.C 91b5444a8184fc2eeaf921adc47fdc55732ab6b2 +++ calendar/dateset.C 47d669b2e0c8d760404084a3101ecc1c527612e6 @@ -47,6 +47,7 @@ class DateSetRep { virtual DateSetRep* copy() const = 0; virtual DateSet::RepeatType type() const = 0; virtual void describe(charArray*) const = 0; + virtual void describe_terse(charArray*) const = 0; virtual int contains(Date) const = 0; virtual int search(Date, Date&) const = 0; @@ -81,6 +82,7 @@ class EmptyDateSetRep : public DateSetRe virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -99,6 +101,7 @@ class SingleDateSetRep : public DateSetR virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -120,6 +123,7 @@ class DayBasedDateSetRep : public DateSe virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -151,6 +155,7 @@ class MonthBasedDateSetRep : public Date virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -196,6 +201,7 @@ class WeekSetDateSetRep : public DateSet virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -220,6 +226,7 @@ class MonthSetDateSetRep : public DateSe virtual DateSetRep* copy() const; virtual DateSet::RepeatType type() const; virtual void describe(charArray*) const; + virtual void describe_terse(charArray*) const; virtual int contains(Date) const; virtual int search(Date, Date&) const; @@ -374,6 +381,15 @@ void DateSet::describe(charArray* buffer rep->describe(buffer); } +void DateSet::describe_terse(charArray* buffer) const { + normalize(); + format(buffer, "%d %d {", start.EpochDays(), finish.EpochDays()); + for (int i = 0; i < deleted.size(); i++) + format(buffer, " %d", deleted[i].EpochDays()); + append_string(buffer, " } "); + rep->describe_terse(buffer); +} + void DateSet::set_empty() { start = Date::First(); finish = Date::Last(); @@ -870,6 +886,10 @@ void EmptyDateSetRep::describe(charArray append_string(buffer, "Empty"); } +void EmptyDateSetRep::describe_terse(charArray* buffer) const { + append_string(buffer, "empty"); +} + int EmptyDateSetRep::contains(Date) const { return 0; } @@ -910,6 +930,10 @@ void SingleDateSetRep::describe(charArra append_date(buffer, date); } +void SingleDateSetRep::describe_terse(charArray* buffer) const { + format(buffer, "single"); +} + int SingleDateSetRep::contains(Date d) const { return (!deleted && (d == date)); } @@ -988,6 +1012,10 @@ void DayBasedDateSetRep::describe(charAr } } +void DayBasedDateSetRep::describe_terse(charArray* buffer) const { + format(buffer, "daily %d", interval); +} + int DayBasedDateSetRep::contains(Date d) const { int diff = ABS(d - anchor); return ((diff % interval) == 0); @@ -1108,6 +1136,22 @@ void MonthBasedDateSetRep::describe(char } } +void MonthBasedDateSetRep::describe_terse(charArray* buffer) const { + int index; + format(buffer, "monthly %d", interval); + switch(mtype) { + case ByDay: + format(buffer, " day %d", backward ? -count : count); + break; + case ByWorkDay: + format(buffer, " workday %d", backward ? -count : count); + break; + case ByWeek: + format(buffer, " week %d %d", backward ? -count : count, weekday.Index()); + break; + } +} + int MonthBasedDateSetRep::contains(Date d) const { int dDay, dYear; Month dMonth; @@ -1382,6 +1426,15 @@ void WeekSetDateSetRep::describe(charArr } } +void WeekSetDateSetRep::describe_terse(charArray* buffer) const { + format(buffer, "weekly {"); + for (int i = 1; i <= 7; i++) { + if (days.Member(i)) + format(buffer, " %d", i); + } + append_string(buffer, " }"); +} + int WeekSetDateSetRep::contains(Date date) const { int d, y; Month m; @@ -1520,6 +1573,20 @@ void MonthSetDateSetRep::describe(charAr append_string(buffer, "Complex Monthly Repetition"); } +void MonthSetDateSetRep::describe_terse(charArray* buffer) const { + append_string(buffer, "monthset {"); + for (int i = 1; i <= 12; i++) { + if (months.Member(i)) + format(buffer, " %d", i); + } + append_string(buffer, " } {"); + for (int i = 1; i <= 31; i++) { + if (days.Member(i)) + format(buffer, " %d", i); + } + append_string(buffer, "}"); +} + int MonthSetDateSetRep::contains(Date date) const { int d, y; Month m; ============================================================ --- calendar/dateset.h 48302f784a8de12f77c76f4b02a344aa14380b11 +++ calendar/dateset.h 3961d71b39f4a7be23dfb954b52370effa7172ce @@ -119,6 +119,14 @@ class DateSet { void describe(charArray* buffer) const; /* + * modifies "buffer". + * effects Append brief but complete item description to "buffer". + * No "null" character is stored in "buffer". + * + */ + void describe_terse(charArray* buffer) const; + + /* * modifies *this * effects post(*this) = the empty set */ ============================================================ --- calendar/item.C 53f19e759535e590214c976f121d316aff047899 +++ calendar/item.C bfdc8ed4ea39fa402e0228d2bd21c018cebfb4ec @@ -726,6 +726,10 @@ void Item::describe(charArray* buffer) c date->describe(buffer); } +void Item::describe_terse(charArray* buffer) const { + date->describe_terse(buffer); +} + int Item::first(Date& result) const { if (!date->first(result)) return 0; if (!todo || done) return 1; ============================================================ --- calendar/item.h 2a5c913c700e3af2e1f4c503be016db8bbfa6baa +++ calendar/item.h 116553e50d9d4bb19025a402927347195772b55d @@ -56,6 +56,7 @@ class Item { int empty() const; DateSet::RepeatType repeat_type() const; void describe(charArray* buffer) const; + void describe_terse(charArray* buffer) const; int first(Date& result) const; int next(Date d, Date& result) const; ============================================================ --- item_tcl.C 33a46326bcaa1a2f4308024ec052139cceecd465 +++ item_tcl.C 2cce178db5f8734d57fcdf993911760f4ecb25fc @@ -87,6 +87,7 @@ static int item_desc (ClientData, Tcl_In static int item_first (ClientData, Tcl_Interp*, int, const char*[]); static int item_type (ClientData, Tcl_Interp*, int, const char*[]); static int item_desc (ClientData, Tcl_Interp*, int, const char*[]); +static int item_repeat_terse (ClientData, Tcl_Interp*, int, const char*[]); static int item_cont (ClientData, Tcl_Interp*, int, const char*[]); static int item_next (ClientData, Tcl_Interp*, int, const char*[]); static int item_range (ClientData, Tcl_Interp*, int, const char*[]); @@ -136,6 +137,7 @@ static Dispatch_Entry item_dispatch[] = { "range", 2, 2, item_range }, { "type", 0, 0, item_type }, { "describe_repeat", 0, 0, item_desc }, + { "repeat_terse", 0, 0, item_repeat_terse }, { "date", 1, 1, item_date }, { "dayrepeat", 2, 2, item_dayr }, @@ -569,6 +571,15 @@ static int item_desc(ClientData c, Tcl_I return TCL_OK; } +static int item_repeat_terse(ClientData c, Tcl_Interp *tcl, int argc, const char *argv[]) { + Item_Tcl* item = (Item_Tcl*) c; + charArray buffer; + item->value()->describe_terse(&buffer); + buffer.append('\0'); + Tcl_SetResult(tcl, buffer.as_pointer(), TCL_VOLATILE); + return TCL_OK; +} + static int item_cont(ClientData c, Tcl_Interp* tcl, int argc, const char* argv[]) { Item_Tcl* item = (Item_Tcl*) c; int dateDays;