selected_char_kind.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2008-2022 Free Software Foundation, Inc.
  2. Contributed by Paul Brook <paul@nowt.org>
  3. This file is part of the GNU Fortran 95 runtime library (libgfortran).
  4. Libgfortran is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public
  6. License as published by the Free Software Foundation; either
  7. version 3 of the License, or (at your option) any later version.
  8. Libgfortran is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #include "libgfortran.h"
  20. #include <strings.h>
  21. extern GFC_INTEGER_4 selected_char_kind (gfc_charlen_type, char *);
  22. export_proto(selected_char_kind);
  23. GFC_INTEGER_4
  24. selected_char_kind (gfc_charlen_type name_len, char *name)
  25. {
  26. gfc_charlen_type len = fstrlen (name, name_len);
  27. if ((len == 5 && strncasecmp (name, "ascii", 5) == 0)
  28. || (len == 7 && strncasecmp (name, "default", 7) == 0))
  29. return 1;
  30. else if (len == 9 && strncasecmp (name, "iso_10646", 9) == 0)
  31. return 4;
  32. else
  33. return -1;
  34. }