patchGNU Octave - Patches: patch #10541, Get first sentence of help string...

 
 

patch #10541: Get first sentence of help string right, in the presence of UTF-8 characters

Submitter:  Rafael Laboissière <rlaboiss>
Submitted:  Fri 19 Sep 2025 05:54:06 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Mon 03 Nov 2025 11:36:50 AM UTC, comment #1: 

cc'ing mmuetzel as IMO he may be the one to judge this; but he doesn't seem to read the patch tracker very often :-)

Philip Nienhuis <philipnienhuis>
Group Member
Fri 19 Sep 2025 05:54:06 AM UTC, original submission:  

The get_first_help_sentence() function may produce incorrect output if the documentation string of the argument passed in contains UTF-8 characters.

I encountered this issue with the regress function of the statistics package (version 1.7.5). Its documentation string begins with:


## -*- texinfo -*-
## @deftypefn  {statistics} {[@var{b}, @var{bint}, @var{r}, @var{rint}, @var{stats}] =} regress (@var{y}, @var{X}, [@var{alpha}])
##
## Multiple Linear Regression using Least Squares Fit of @var{y} on @var{X}
## with the model @code{y = X * beta + e}.


get_first_help_sentence("regress") produces the following:


octave:1> pkg load statistics
octave:2> get_first_help_sentence("regress")
ans = Multiple Linear Regression using Least Squares Fit of Y on X with the
model �...


We can see that the character "‘" (U+2018, Left single quotation mark), which happens to be the 77th character in the string, is handled incorrectly and the resulting doc-cache has an invalid encoding.

With the patch, the result is correct:


octave:1> pkg load statistics
octave:2> get_first_help_sentence("regress")
ans = Multiple Linear Regression using Least Squares Fit of Y on X with the
model ‘...


Note that I added a BIST to scripts/help/get_first_help_sentence.m. For that to work, I included a new file scripts/help/_test_function_with_utf_8_doc_string__.m, containing the following documentation string:


## -*- texinfo -*-
## This is a very naïve function


I am not sure whether this is appropriate.

Rafael Laboissière <rlaboiss>

 

Attached Files

Attached Files

(Note: upload size limit is set to 4.0MiB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by philipnienhuis (Posted a comment)
  • -email is unavailable- added by philipnienhuis
  • -email is unavailable- added by rlaboiss (Submitted the item)
  •  

    Votes

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    History

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-11-03 philipnienhuis Carbon-Copy- Added mmuetzel
    2025-09-19 rlaboiss Attached File- Added first-sentence-help-utf-8.patch, #57668

    Back to the top

    Powered by Savane 3.16-8b18.
    Corresponding source code