unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Bruce Korb <bkorb@gnu.org>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel Development <guile-devel@gnu.org>
Subject: Re: Program received signal SIGSEGV, Segmentation fault.
Date: Sat, 17 Nov 2012 10:12:18 -0800	[thread overview]
Message-ID: <50A7D382.9060609@gnu.org> (raw)
In-Reply-To: <876254svsx.fsf@tines.lan>

On 11/16/12 20:22, Mark H Weaver wrote:
> Bruce, if you refuse to fix these problems properly, you will end up

Hi Mark,

My program's intent is to read text from two inputs and weave them
together.  It has no need to know or understand the encoding in any way,
other than to communicate exception messages to the user.
Read the inputs, transform the text, write the output.
ISO-8859-1 or UTF8 or unsimplified Chinese input, doesn't matter.
It only matters that it be NUL byte delimitable, and all encodings
support that.  User messages are not involved here.

> with a broken program.  Period.  Full stop.  Most modern distributions
> use UTF-8 by default, and if you simply write a bare 0xA9 to the
> terminal or output file, that's not going to look right on their
> terminal or editor.

It was a data character, not part of my program.
I am trying to get that character to flow through my program
from my inputs to the output file, but I am having trouble with
the Guile functions that transform the data.  I want to hand the
Guile library a string, a la
   (define my-val (get "val-string"))
where "get" is a function that pulls bytes from the input.
Then, later on,  insert it into the output with:
    (emit my-val)
and have *exactly* what was gotten from the input.
I do not care in the slightest what the current locale is.
I pulled in some arbitrary data with ``(get "val-string")''
and now I want those exact bytes to be emitted where I
have the ``(emit my-val)'' invocation.

> But if that's really what you want, fine, here's how you do it:
> 
>   (fluid-set! %default-port-encoding "ISO-8859-1")
>   (set-port-encoding! (current-output-port) "ISO-8859-1")
>   (set-port-encoding! (current-input-port) "ISO-8859-1")
>   (set-port-encoding! (current-error-port) "ISO-8859-1")
> 
> and make sure to *not* set the locale.

Every time I have a fragment of scheme code, I have a new port.
Doing it this way would require concatenating that text with
the text to invoke.  That adds an allocate, two string copies
and a free to every scheme invocation.  I'll poke around, but
I am guessing there would have to be some more of this set up
for each scheme sequence, yes?
        {
            SCM ln = AG_SCM_INT2SCM(line);
            scm_set_port_filename_x(port, file);
            scm_set_port_line_x(port, ln);
            scm_set_port_column_x(port, SCM_INUM0);
        }



  reply	other threads:[~2012-11-17 18:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 18:00 Program received signal SIGSEGV, Segmentation fault Bruce Korb
2012-11-16 19:19 ` Mark H Weaver
2012-11-16 19:50   ` Bruce Korb
2012-11-16 20:20     ` Bruce Korb
2012-11-16 21:23       ` Mark H Weaver
2012-11-16 23:32         ` Bruce Korb
2012-11-17  2:19           ` Noah Lavine
2012-11-17 20:22             ` Bruce Korb
2012-11-17  4:22           ` Mark H Weaver
2012-11-17 18:12             ` Bruce Korb [this message]
2012-11-17 19:56               ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50A7D382.9060609@gnu.org \
    --to=bkorb@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).