[Glass] Comment of #newDay:monthNumber:year: is wrong (and I do not like the behavior either!)

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Mon Aug 10 19:05:15 PDT 2015


On Mon, Aug 10, 2015 at 10:30 PM, Richard Sargent <
richard.sargent at gemtalksystems.com> wrote:

> Double each \. So, \\\\ gets you \\ after escape processing.
>

Yes, I tried that but I still got only one \. That's weird. I will try
again.
Thanks


> On Aug 10, 2015 6:06 PM, "Mariano Martinez Peck via Glass" <
> glass at lists.gemtalksystems.com> wrote:
>
>>
>> Thanks Dale.. BTW...how can I put #\\ and comments in a bash script of
>> topaz?  I am doing something like this:
>>
>>
>> su -m $GEMSTONE_USER -c "$GEMSTONE/bin/topaz -l -I
>> $APPLICATION_DIR/.topazini -T200000 <<EOF
>>
>> display oops
>> iferror where
>> set user SystemUser pass $2
>> login
>>
>> run
>>
>> Date compile.....
>>
>> %
>>
>> commit
>> logout
>>
>> EOF
>> "
>>
>> Problem is that the selectors \\ are replaced by \  and comments can't
>> get compiled. If I run this from a topaz console, it works, but from this
>> bash it doesn't. So it's clearly a bash escaping issue.
>>
>> Any idea what the magic escaping is?
>>
>> Thanks!
>>
>>
>> On Mon, Aug 10, 2015 at 9:03 PM, Dale Henrichs <
>> dale.henrichs at gemtalksystems.com> wrote:
>>
>>> Thanks Mariano,
>>>
>>> It looks good. I've attached your patch to the internal bug .... I'll
>>> let you know how things go ...
>>>
>>> Dale
>>>
>>>
>>> On 08/10/2015 03:46 PM, Mariano Martinez Peck wrote:
>>>
>>> Date  class compileMethod: ' numberOfDaysIn: month year: aYear
>>>
>>> ((month == 1) or: [(month == 3) or: [(month == 5) or: [(month == 7) or:
>>>    [(month == 8) or: [(month == 10) or: [(month == 12)]]]]]])
>>>    ifTrue: [^ 31].
>>> ((month == 4) or: [(month == 6) or: [(month == 9) or: [(month == 11)]]])
>>>    ifTrue: [^ 30].
>>> (((aYear \\ 100) == 0)
>>>    ifTrue: [ ((aYear \\ 400) == 0)]
>>>    ifFalse: [ ((aYear \\ 4) == 0) ])
>>>   ifTrue: [^ 29].
>>> ^ 28
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Accessing'
>>> environmentId: 0.
>>>
>>>
>>>
>>> Date  class compileMethod: '_newDay: day monthNumber: month year: year
>>>
>>> <primitive: 316>
>>>
>>> day _validateClass: SmallInteger .
>>> month _validateClass: SmallInteger .
>>> year _validateClass: SmallInteger .
>>>
>>> ^ self _primitiveFailed: #newDay:monthNumber:year:
>>>        args: { day . month . year }
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Instance Creation'
>>> environmentId: 0.
>>>
>>>
>>> Date  class compileMethod: 'newDay: day monthNumber: month year: year
>>>
>>> (month between: 1 and: 12) ifFalse: [ self error: ''Incorrect specified
>>> month: '', month asString].
>>> (day between: 1 and: (self numberOfDaysIn: month year: year)) ifFalse: [
>>> self error: ''Incorrect specified day: '', day asString].
>>>
>>> ^ self _newDay: day monthNumber: month year: year
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Instance Creation'
>>> environmentId: 0.
>>>
>>>
>>>
>>> Date compileMethod: 'addMonths: anInteger
>>>
>>> "Returns a Date that describes a date anInteger months later than that
>>> of the
>>>  receiver.
>>>
>>>  This method attempts to keep the day of the month the same.  If the
>>>  new month has fewer days than the receiver''s original month, then it
>>>  truncates to the last day of the new month."
>>>
>>> | yr month day newYear newMonth newDay newDate generatedDay |
>>>
>>> yr := self year.
>>> month := self month.
>>> day := self day.
>>>
>>> newMonth := month + anInteger.
>>> newYear := yr + ((newMonth - 1) // 12).
>>> newMonth := (newMonth - 1) \\ 12 + 1.
>>> newDate := self class _newDay: day monthNumber: newMonth year: newYear.
>>> generatedDay := newDate day.
>>> (generatedDay ~= day)
>>>   ifTrue: [
>>>     newDay := newDate _daysInMonth: newMonth.
>>>     newDate := self class _newDay: newDay monthNumber: newMonth year:
>>> newYear
>>>     ].
>>> ^ newDate.
>>>
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Arithmetic'
>>> environmentId: 0.
>>>
>>>
>>> Date compileMethod: 'addYears: anInteger
>>>
>>> "Returns a Date that describes a date anInteger years later than that of
>>> the
>>>  receiver."
>>>
>>> | yr month day newYear newDay newDate generatedDay |
>>>
>>> yr := self year.
>>> month := self month.
>>> day := self day.
>>>
>>> newYear := yr + anInteger.
>>> newDate := self class _newDay: day monthNumber: month year: newYear.
>>> generatedDay := newDate day.
>>> (generatedDay ~= day)
>>>   ifTrue: [
>>>     newDay := newDate _daysInMonth: month.
>>>     newDate := self class _newDay: newDay monthNumber: month year:
>>> newYear
>>>     ].
>>> ^ newDate.
>>>
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Arithmetic'
>>> environmentId: 0.
>>>
>>>
>>> Date class compileMethod: 'newDay: day year: year
>>>
>>> "Creates and returns an instance of the receiver from the specified
>>> values.
>>>  Generates an error if any of the values are out of range."
>>>
>>> ^ self _newDay: day monthNumber: 1 year: year.
>>>
>>> '
>>> dictionaries: GsSession currentSession symbolList
>>> category: 'Instance Creation'
>>> environmentId: 0.
>>>
>>>
>>> System commit.
>>>
>>>
>>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>> _______________________________________________
>> Glass mailing list
>> Glass at lists.gemtalksystems.com
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>>
>>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20150810/8ef4d365/attachment.html>


More information about the Glass mailing list