Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port string #1585

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Port string #1585

wants to merge 4 commits into from

Conversation

A6GibKm
Copy link

@A6GibKm A6GibKm commented Aug 24, 2020

DEFUN ("string", Fstring, Sstring, 0, MANY, 0,
       doc: /*
Concatenate all the argument characters and make the result a string.
usage: (string &rest CHARACTERS)  */)
  (ptrdiff_t n, Lisp_Object *args)
{
  ptrdiff_t i;
  int c;
  unsigned char *buf, *p;
  Lisp_Object str;
  USE_SAFE_ALLOCA;

  SAFE_NALLOCA (buf, MAX_MULTIBYTE_LENGTH, n);
  p = buf;

  for (i = 0; i < n; i++)
    {
      CHECK_CHARACTER (args[i]);
      c = XINT (args[i]);
      p += CHAR_STRING (c, p);
    }

  str = make_string_from_bytes ((char *) buf, n, p - buf);
  SAFE_FREE ();
  return str;
}

@A6GibKm
Copy link
Author

A6GibKm commented Aug 24, 2020

Fails with

Loading international/mule-cmds...
Loading case-table...
Loading /var/home/deathwish/.opt/remacs/lisp/international/charprop.el (source)...
Loading international/characters...
Wrong type argument: stringp, 8262
make[1]: *** [Makefile:807: bootstrap-emacs] Error 255

@A6GibKm
Copy link
Author

A6GibKm commented Aug 25, 2020

Similar to char_to_string.

@A6GibKm A6GibKm marked this pull request as ready for review August 25, 2020 02:30
@A6GibKm A6GibKm marked this pull request as draft August 25, 2020 02:42
@A6GibKm A6GibKm marked this pull request as ready for review August 25, 2020 02:46
Copy link
Collaborator

@db48x db48x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly perfect!

test/rust_src/src/fns-tests.el Outdated Show resolved Hide resolved
Comment on lines +108 to +109
let n = args.len();
let mut buffer = vec![0_u8; n * MAX_MULTIBYTE_LENGTH];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let n = args.len();
let mut buffer = vec![0_u8; n * MAX_MULTIBYTE_LENGTH];
let mut buffer = vec![0_u8; args.len() * MAX_MULTIBYTE_LENGTH];

did this because I see nowhere else n is used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n is used in make_string_from_bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants