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

ChangeTag and changeStreamCCSID print garbage #426

Open
Martin-Zeithaml opened this issue Feb 7, 2024 · 8 comments
Open

ChangeTag and changeStreamCCSID print garbage #426

Martin-Zeithaml opened this issue Feb 7, 2024 · 8 comments
Assignees
Labels
bug Something isn't working new not yet triaged

Comments

@Martin-Zeithaml
Copy link
Contributor

Martin-Zeithaml commented Feb 7, 2024

How to replicate

Simple testcht.js:

import * as zos from 'zos'
let result = zos.changeTag('./a.txt', 0);

File a.txt exists, t ISO8859-1 T=on a.txt.

Running the script:

zowe/bin/utils/configmgr -script testcht.js
��/��ʀ�/�%������ǀ���>?�����

The garbage on the screen is printed here.

Problem 1

printf is for some reason producing garbage.

Example

When the error message was changed: printf("abcd0123") will produce X'2FC2C4C0 90911693'
Is this encoding problem?

Problem 2

It does not work, the js code should remove the tag, which remains unchanged.

@Martin-Zeithaml Martin-Zeithaml added bug Something isn't working new not yet triaged labels Feb 7, 2024
@1000TurquoisePogs 1000TurquoisePogs self-assigned this Feb 14, 2024
@1000TurquoisePogs
Copy link
Member

1000TurquoisePogs commented Feb 16, 2024

This isn't what I thought at first.
changeTag DOES work - sometimes.
if you do 1047 instead of 0, it works.
It looks like basically any number except 0 works.
There's some edge case around 0 (remove tag)
When it works it does not print garbage.

@1000TurquoisePogs
Copy link
Member

i think the cause is here
https://github.com/JoeNemo/quickjs-portable/blob/main/porting/polyfill.c#L142
the conditional says text or binary. 0 is neither.

@Martin-Zeithaml
Copy link
Contributor Author

I have noticed this difference, when used zos.zstat for

  • File ISO8859-1: "isText":true,"ccsid":819
  • Untagged file: "isText":false,"ccsid":0

This seems to help:

#define CCSID_NONE 0
...
  if (ccsid == CCSID_NONE || ccsid == CCSID_BINARY ) {
    attr.att_filetag.ft_txtflag = 0;
  } else {
    attr.att_filetag.ft_txtflag = 1;
  }

However the printf problem remains.

@Martin-Zeithaml
Copy link
Contributor Author

printf of EBCDIC hex code is working:
printf("\xC8\x85\x93\x93\x96\x6B\x40\xA6\x96\x99\x93\x84\x5A"); -> Hello, world!

I am guessing, this is some #define, compiler option or something missing.

@Martin-Zeithaml
Copy link
Contributor Author

toEBCDIC or printf2 should help.

@Martin-Zeithaml
Copy link
Contributor Author

@Martin-Zeithaml Martin-Zeithaml changed the title ChangeTag prints garbage and does not work ChangeTag prints garbage Feb 22, 2024
@Martin-Zeithaml
Copy link
Contributor Author

Problem 1

Garbage on the screen remains.
Most likely caused by not using printf2.
This can be reproduced when __chattr will fail, e.g. zos.changeTag('file which does not exist', 0);

Problem 2

Merged, working fine.

@Martin-Zeithaml
Copy link
Contributor Author

Martin-Zeithaml commented Sep 26, 2024

@Martin-Zeithaml Martin-Zeithaml changed the title ChangeTag prints garbage ChangeTag and changeStreamCCSID print garbage Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants